2015-11-03 12:00:44 -08:00
|
|
|
// newio/AvailableCharSets.java
|
2016-12-30 17:23:13 -08:00
|
|
|
// (c)2017 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.
|
2016-09-23 13:23:35 -06:00
|
|
|
// Visit http://OnJava8.com 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
|
2017-05-10 11:45:39 -06:00
|
|
|
EUC-KR: ksc5601-1987, csEUCKR, ksc5601_1987, ksc5601,
|
|
|
|
5601,
|
2015-06-15 17:47:35 -07:00
|
|
|
euc_kr, ksc_5601, ks_c_5601-1987, euckr
|
|
|
|
GB18030: gb18030-2000
|
2017-05-10 11:45:39 -06:00
|
|
|
GB2312: gb2312, euc-cn, x-EUC-CN, euccn, EUC_CN,
|
|
|
|
gb2312-80,
|
2015-06-15 17:47:35 -07:00
|
|
|
gb2312-1980
|
|
|
|
...
|
2015-09-07 11:44:36 -06:00
|
|
|
*/
|