Abeish Babu

Friday, October 30, 2009

I had a difficult time to implement Chinese characters for my SWT application. I was using resource bundle for internationalizing the application. While creating resource bundles for Chinese characters I noticed that resource bundles will accept only ASCII and Java is not able to read UTF-8 resource bundles.I was using eclipse as my development IDE.

The following work around helped me to overcome the situation.

Open an existing MessageBundle.properties file outside eclipse using notepad. Enter Chinese characters for the translation you want and save the file in UTF-8 format. You can use google translation for getting the chinese characters.

Use the tool 'native2ascii' to convert the chinese charcters to unicode characters.

The Chinese.properties file will contain Unicode characters for your Chinese letters in MessageBundle.properties. Then copy the content in Chinese.properties file and copy it to any MessageBundle.properties file created in eclipse.

The program will work fine displaying Chinese characters without any modification to source code.

Tuesday, October 27, 2009

I have faced a difficult situation where one of the scenario require to write and preserve comments in configuration file. I tried using properties file and ini file concept using java. But when we write back to the file for storing configuration information, the entire comments in the proprieties or ini file get lost.

At last after a frantic search, I got the following free library which will help you to store configuration in an ini file where you can read and write and it will preserve any comments wrtitten at the top of the file.