utf-8 – Encode loss when minimizing javascript in Grails


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 in the browser, the word appears as: "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, it appears the word like: "service". When the message appears on the screen, it displays: "service"

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

But the solution of using "-Dfile.encoding=UTF-8" didn't work for me.

I tried with the commands below and nothing:

grails -Dfile.encoding=UTF-8 package

gradle -Dfile.encoding=UTF-8 assetCompile


Victor, this has already happened to me, the following is the encoding of your request's response is different from UTF-8, which is the reason for this inconvenience, what you can do is set this manually inside your controller's action, or you can create a Grails interceptor and set the enconding on all your requests, I did that in my application and it works perfectly, follow the interceptor code.

class EncodingInterceptor {

    public EncodingInterceptor(){
        match controller: '*'

    boolean before() {
        response.characterEncoding = 'UTF-8'
Scroll to Top