OnJava8-Examples/newio/AvailableCharSets.java

42 lines
1.3 KiB
Java
Raw Normal View History

2015-11-03 12:00:44 -08:00
// newio/AvailableCharSets.java
2015-12-15 11:47:04 -08:00
// (c)2016 MindView LLC: see Copyright.txt
2015-11-15 15:51:35 -08:00
// We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
2015-06-15 17:47:35 -07:00
// Displays Charsets and aliases
import java.nio.charset.*;
import java.util.*;
public class AvailableCharSets {
public static void main(String[] args) {
SortedMap<String,Charset> charSets =
Charset.availableCharsets();
for(String csName : charSets.keySet()) {
2015-11-03 12:00:44 -08:00
System.out.print(csName);
2015-06-15 17:47:35 -07:00
Iterator aliases = charSets.get(csName)
.aliases().iterator();
if(aliases.hasNext())
2015-11-03 12:00:44 -08:00
System.out.print(": ");
2015-06-15 17:47:35 -07:00
while(aliases.hasNext()) {
2015-11-03 12:00:44 -08:00
System.out.print(aliases.next());
2015-06-15 17:47:35 -07:00
if(aliases.hasNext())
2015-11-03 12:00:44 -08:00
System.out.print(", ");
2015-06-15 17:47:35 -07:00
}
2015-11-03 12:00:44 -08:00
System.out.println();
2015-06-15 17:47:35 -07:00
}
}
2015-09-07 11:44:36 -06:00
}
/* Output: (First 7 Lines)
2015-06-15 17:47:35 -07:00
Big5: csBig5
Big5-HKSCS: big5-hkscs, big5hk, Big5_HKSCS, big5hkscs
CESU-8: CESU8, csCESU-8
EUC-JP: csEUCPkdFmtjapanese, x-euc-jp, eucjis,
Extended_UNIX_Code_Packed_Format_for_Japanese, euc_jp,
eucjp, x-eucjp
EUC-KR: ksc5601-1987, csEUCKR, ksc5601_1987, ksc5601, 5601,
euc_kr, ksc_5601, ks_c_5601-1987, euckr
GB18030: gb18030-2000
GB2312: gb2312, euc-cn, x-EUC-CN, euccn, EUC_CN, gb2312-80,
gb2312-1980
...
2015-09-07 11:44:36 -06:00
*/