0

My application uses Labels for internationalization.

In all pages, the accented characters are shown as unicodes. E.g.,

à ---> \u00E0

I have no idea which can be the problem and I can't find any useful documentation on this topic: I only found http://forum.zkoss.org/question/14643/internationalization-accent-characters/?answer=101862#post-id-101862 but all the suggested links are dead.

Properties file are edited with Eclipse ResourceBundle Editor which saves accented letters as unicode: I don't know why the accented characters are rendered as \uXXXX.

Thanks in advance for the collaboration.

baronKarza
  • 513
  • 6
  • 23

2 Answers2

1

At the end I solved the problem.

IT IS ONLY A PROBLEM OF ENCODING, as chillworld and others in other fora said (thanks for driving me on the right way!).

I had to implement multiple tricks to have my application working correctly:

  1. rename .properties files to .labels: this is because Eclipse assumes that all properties files are ISO-8859-1 encoded and if you want to be sure that it preserves your encoding you have to rename it. Most important, be sure that the files are UTF-8 encoded (right click in Eclipse on the file, click on 'Properties', encoding is in the last line). To modify the encoding you can use an external editor (SublimeText, UltraEdit, Geany, gedit,...) or within Eclipse go to Edit->Set Encoding and choose UTF-8.

  2. avoid using the ResourceBundle Editor eclipse plugin or other properties editors (like JBoss Properties Editor): the problem is that they automatically convert accented letters to escaped unicode sequences because they assumes that the properties files are ISO-8859-1 encoded.

  3. replace all the occurrences of the unicode sequences with the corresponding character (e.g., replace \u00E0 with à, and so on...).

  4. finally, restart Tomcat: it should work.

baronKarza
  • 513
  • 6
  • 23
  • I'll always create them with notepad++, easiest way to get it correct. Netbeans does also have problems with encoding. – chillworld Nov 23 '16 at 15:36
0

Did you bother checking ZK's I18N files?

Here is the first 3 lines of it :

#"charset=utf-8"
#Created on Sept 21, 2006, by Jérôme Vergereau
#Copyright (C) 2006 Potix Corporation

As you can see, it's saved as UTF-8 and not unicode, so please try UTF-8 as encoding.

chillworld
  • 4,207
  • 3
  • 23
  • 50
  • Hi chillworld, thanks a lot for your answer. I did not find the 3 lines you pointed out. Are they in the header of the .properties (ResourceBundle) file? I tried to insert them at the beginning of the properties file but, for time being, I'm still stuck... Thanks again. – baronKarza Nov 23 '16 at 10:54
  • they come from dependency zul.jar => metainfo/mesg. those are comments, not needed in your file, but you need to alter your file encoding to utf-8 and not Unicode. – chillworld Nov 23 '16 at 11:16
  • Thanks, it now works (see my post). The real problem was the usage of the ResourceBundle Editor the automaticcally inserts escaped unicode sequences. And ZK thinks they are legitimate character (coz it assumes the file is UTF-8 encoded) and does not unescape them. Thanks again. – baronKarza Nov 23 '16 at 11:24