Showing posts with label Conversion. Show all posts
Showing posts with label Conversion. Show all posts

Tuesday, 17 January 2017

Java Character Convertion to Unicode with native2ascii Utility

While working on multi language assignment found interesting JAVA utility.

native2ascii : Converts a file with ‘non-Latin 1’ or ‘non-Unicode’ characters to ‘Unicode-encoded’ characters.

Sometimes you need this kind of conversion. As in our case we need this to create multi language  resource bundles. 

Here are the steps :

1. Create file [Resource_Original.properties in our case] and save as UTF-8 format [This option is available in popular editors like NotePad++].

===================================================================
login=Bejelentkezés
personalInformation=Személyes információ
orderHistory=Rendelés történet
paymentInformation=Fizetség információ
===================================================================

2. Now use native2ascii command to convert it into Unicode format.

 native2ascii -encoding UTF-8 Resource_Original.properties Resource_converted.properties

3. Check the converted file [Resource_converted.properties]. 

=================================================================== 
login=Bejelentkez\u00e9s
personalInformation=Szem\u00e9lyes inform\u00e1ci\u00f3
orderHistory=Rendel\u00e9s t\u00f6rt\u00e9net
paymentInformation=Fizets\u00e9g inform\u00e1ci\u00f3
===================================================================