Skip to content

Instantly share code, notes, and snippets.

@mpurbo
Created January 21, 2012 04:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mpurbo/1651273 to your computer and use it in GitHub Desktop.
Save mpurbo/1651273 to your computer and use it in GitHub Desktop.
Converting all double bytes UTF-8 numbers (0-9) in a String to single bytes (0-9)
private static String toHankakuNumbers(String zenkaku) {
if (zenkaku == null)
return null;
StringBuffer ret = new StringBuffer();
char [] src = zenkaku.toCharArray();
for (char c : src) {
if (c >= 0xff10 && c <= 0xff19) {
ret.append((char)(c - 65248));
} else {
ret.append(c);
}
}
return ret.toString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment