I need to convert halfwidth katakana characters to fullwidth characters.
Example:
How can I do this in Java?
I think you are talking about converting "half-width Katakana" Unicode code-points to their regular equivalents.
See here for info, including a listing of the relevant code point values:
I don't know if there is a recommended way to do it (eg a standard API or 3rd-party library), but you could easily write some code to:
StringBuilder
Map
)String
.You could try the icu4j library. It supports a number of transliterations , including Halfwidth-Fullwidth
and Fullwidth-Halfwidth
.
Example:
Transliterator t = Transliterator.getInstance("Halfwidth-Fullwidth");
String result = t.transliterate(original);
Use just standard API (java.text.Normalizer). No need 3rd party solution or dependency.
It converts full-width alphanumeric characters to half-width and half-width katakana to full-width katakana
Normalizer.normalize(text, Normalizer.Form.NFKC)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.