encoding - How to convert from full-width to half-width Japanese characters in Java? -
i'm using class transliterator of icu project convert half-width full-width characters this:
transliterator transliterator = transliterator.getinstance("hiragana-katakana"); string converted = transliterator.transliterate("コンニチハ"); //half-width
the result of converted
is: コンニチハ (full-width)
but:
string converted = transliterator.transliterate("コンニチハ"); //full-width
the result of converted
still: コンニチハ (full-width)
my expectation コンニチハ
. can me solve this?
thanks.
i found answer here. it's simple using different params below:
transliterator transliterator = transliterator.getinstance("halfwidth-fullwidth"); string converted = transliterator.transliterate("コンニチハ"); //half-width
converted
value: コンニチハ
transliterator transliterator = transliterator.getinstance("fullwidth-halfwidth"); string converted = transliterator.transliterate("コンニチハ"); //full-width
converted
value: コンニチハ
Comments
Post a Comment