Loss of Encode when minimizing javascript in Grails

Asked

Viewed 62 times

3

In my javascript file there is a message with the string "service" for example. When I run the project (run-app) and check the javascript by the browser, the word appears as: "§the service". But this is displayed correctly on the screen when the message is invoked.

But when I run the system through a generated package (package), and check the javascript by the browser, the word appears as: "servi u00c3 u00a7o". When the message appears on the screen, it is displayed: "service§the"

I found a person with the same problem as mine, on that link: https://github.com/bertramdev/grails-asset-pipeline/issues/322

However the solution of using "-Dfile.encoding=UTF-8" did not work for me.

I tried with the commands below and nothing:

grails -Dfile.encoding=UTF-8 package

Gradle -Dfile.encoding=UTF-8 assetCompile

1 answer

0

Victor this has already happened to me, is the following the encoding of the Answer of your request is different from UTF-8, which is the reason for this disorder, what you can do is to manually arrow this within the action of your controller, or you can create a Grails Interceptor and set the enconding in all your requests, I did it in my application and works perfectly, follows the code of the Interceptor.

class EncodingInterceptor {

    public EncodingInterceptor(){
        match controller: '*'
    }

    boolean before() {
        response.characterEncoding = 'UTF-8'
    }
}
  • It doesn’t make much sense in my case, because the encoding error is in javascript and not in the return of requests.

  • Guy takes a look at the enconding from Sponse, and sees if that’s not it, if that’s not it, provençally is the file’s enconding, have you set it in your IDE.

  • No friend, it has no relation to Sponse and has no problem in the file encoding. As I described in doubt, the system works normally, the problem occurs only when the package is generated (because javascript is minimized in a single file)

  • Hm..., you have checked the Respse encoding of this js file?

  • yes it is UTF-8 as the rest of the files.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.