i am not too familiar with java (coming from c++/c#). I have a need for to use java in order to convert some documents from halfwidth japanese charaters to full width.
would someone be kind and provide some example to start with. i have not had luck to finding some sample.
just a note it has to be in Java.
Found this on Japanese blogger Arai's site:
String data1 = "全角ひらがな"; // full-width hiragana
String data2 = "全角カタカナ"; // full-width katakana
String data3 = "半角カタカナ"; // half-width katakana
Transliterator transliterator = Transliterator.getInstance("Hiragana-Katakana");
System.out.println(transliterator.transliterate(data1));
System.out.println(transliterator.transliterate(data2));
System.out.println(transliterator.transliterate(data3));
This should result in all 3 Japanese strings being transliterated as you would expect. Give this a shot a let me know if it doesn't work.
Have you seen the ICU userguide and ICU APIdoc on the topic? You can use the Transliterator demo to check the behavior, such as "Halfwidth-Fullwidth"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With