ひらがな→カタカナの変換
StringBuffer buf = new StringBuffer(); for (int i = 0; i < str.length(); i++) { char code = str.charAt(i); if ((code >= 0x3041) && (code <= 0x3093)) { buf.append((char) (code + 0x60)); } else { buf.append(code); } }
カタカナ→ひらがなの変換
StringBuffer buf = new StringBuffer(); for (int i = 0; i < str.length(); i++) { char code = str.charAt(i); if ((code >= 0x30a1) && (code <= 0x30f3)) { buf.append((char) (code - 0x60)); } else { buf.append(code); } }