Character encoding in minified js
Closed this issue · 4 comments
Having the string with symbols such as: ĄČĘĖĮĮŠŲŪŪ replaces them with question marks when compiled. Though this does not seem to be the problem when trying to compile JS with such string in http://closure-compiler.appspot.com/home Closure compiler in appspot replaces them with the equivalent unicode character codes.
I just added a test for UTF-8 here: 64a5c0a
It runs fine on my machine™.
I wonder how I can reproduce your problem in tests. Could you maybe send me a minimal file that doesn't work for you?
This is taking a bit more effort to fix than I can do inbetween tasks at work. Especially since I'm having a hard time reproducing it - even with your emailed file. I'll dive deeper into the problem, but if you are able to create a test case in optimus that fails, that would be very helpful indeed.
Hi @zilvinasu
On irc you said:
I figured out the problem, the compiled file from response is of charset=usa-acsii there is no way it would represent UTF-8 chars correctly. Though I am not quite sure if it's more js minifier output related, or some sort of response problem in middle ware. Because before adding optimus on top of it everything was just fine.
Does this mean your problem is solved?
I guess it would still be nice to be able to specify the encoding when loading an asset.
As for the reason: My guess is that earlier Ring would just pipe the bytes through unchanged - but with Optimus there is some middleware that actually has to enterpret it as a String with chars - and that made the error pop up.
Yeah, you are right, it's Ring that fails at delivering the content properly. If I force charset on our response in some middleware it seems to work properly
(ring.util.response/charset _ "utf-8")