Sunday, May 11, 2008

How to learn a new groovy friend Italian accents (and not only)

While updating my webpage-pieces-merger to be groovy, I noticed some odd problem on Italian accents (same would be for German umlaute and so on).

So what is going on with UTF-8?? Why is the encoding wrong, when my java encoding is always right?

When I have a look at the, I notice that the encoding is:

Alright, so I just have to change that one?
try 1) groovy -c UTF-8 myScript -> NOT WORKING

try 2) first set the encoding in the java options on the console:
export JAVA_OPTS=-Dfile.encoding=UTF-8
after that I get a nice file.encoding=UTF-8

and the text is ok:

so what about setting the property inside the script?

try 3) inside the myScript set System.setProperty("file.encoding","UTF-8")
Nice, I get file.encoding=UTF-8 but for some reason the accents are messed up again.

I really wonder why try 3 is not working, probably setting this inside the process is too late? Wrong JVM? Hmmm... really no idea about it. Try 2 is working ok, but I don't like the fact that I have to set a system variable before. I hope to find a solution soon.
Post a Comment