Created
January 21, 2012 04:22
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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