dandelion / dandelion-datatables

Dandelion component for DataTables
http://dandelion.github.io/components/datatables/
Other
110 stars 49 forks source link

Wrong encoding in JS configuration #300

Open ForNeVeR opened 9 years ago

ForNeVeR commented 9 years ago

Consider this resources/dandelion/datatables/datatables.properties:

global.i18n.msg.info=\u041F\u043E\u043A\u0430\u0437\u0430\u043D\u044B \u0437\u0430\u043F\u0438\u0441\u0438 _START_\u2014_END_ \u0438\u0437 _TOTAL_

(That's properly uglified Russian Unicode, that will render as "Показаны записи STARTEND из TOTAL"; I have to "uglify" that with native2ascii due to Java handling of .properties files.)

It seems to work correctly (I've traced it to com.github.dandelion.core.scripting.ScriptingUtils.prettyPrintJs and it looks like a valid Unicode string there).

But when my browser downloads configuration JS file (such as /dandelion-assets/08dc0a3672b81af9bb2af7b4ff3c7b20/4c8a49b8ef4515c81a3671199b122b1c/js/dandelion-datatables-d09e05f878ceffc9f7dc3360b71dbdcc.js) after the initial Datatable loading, all that Unicode is totally scrambled; it looks like

    "language": {
        "sInfo": "Показаны записи _START_\u2014_END_ из _TOTAL_",
        "sEmptyTable": "Таблица не содержит данных"
    },

I've checked the headers for this dandelion-datatables-*.js response and they're all okay: it is reported as a valid UTF-8 file but it does not include the content I see in debugger and I want to see in the output.

What am I doing wrong here?

I think that there's encoding problem somewhere (it looks like some component decodes Unicode bytes to my OS default encoding), but I still haven't found the server code that renders this JavaScript config to the HTTP request output stream.

Also I have no luck with setting my own MessageResolver - it gets loaded and created, but its getResource method never gets called (maybe that's distinct problem and I will file another issue if you want).

ForNeVeR commented 9 years ago

I think that there's encoding problem somewhere (it looks like some component decodes Unicode bytes to my OS default encoding)

That's right because the problem was locally solved by setting -Dfile.encoding=UTF-8. But that means that Dandelion is messing the encodings somewhere and using the default one instead of UTF-8.

tduchateau commented 9 years ago

Thanks for reporting, and for your investigation. I'll look into this before the next release.

ForNeVeR commented 8 years ago

FYI, this bug will be fixed with my PR to the main repository: https://github.com/dandelion/dandelion/pull/108