Created
October 16, 2012 14:55
-
-
Save megascus/3899786 to your computer and use it in GitHub Desktop.
使用出来る文字コード一覧
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
public class CharSetMain { | |
public static void main(String[] args) { | |
for (Charset cs : Charset.availableCharsets().values()) { | |
System.out.println(charsetToString(cs)); | |
} | |
} | |
private static String charsetToString(Charset cs) { | |
return cs.name() + aliasesToString(cs); | |
} | |
private static String aliasesToString(Charset cs) { | |
Set<String> aliases =cs.aliases(); | |
if (aliases.isEmpty()) { | |
return "[]"; | |
} | |
StringBuilder b = new StringBuilder(); | |
b.append("["); | |
for (String name : aliases) { | |
b.append(name); | |
b.append(", "); | |
} | |
b.delete(b.length() - 2, b.length()); | |
b.append("]"); | |
return b.toString(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment