Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Encoding CharsetNames for Charset.forName(String)

I have a question about Charset.forName(String charsetName). Is there a list of charsetNames I can refer to? For example, for UTF-8, we use "utf8" for the charsetName. What about WINDOWS-1252, GB18030, etc.?

like image 752
Jason Ching Avatar asked Sep 23 '12 23:09

Jason Ching


2 Answers

Charset         Description

US-ASCII        Seven-bit ASCII, a.k.a. ISO646-US, a.k.a. the Basic Latin block of the Unicode character set
ISO-8859-1      ISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1
UTF-8           Eight-bit UCS Transformation Format
UTF-16BE        Sixteen-bit UCS Transformation Format, big-endian byte order
UTF-16LE        Sixteen-bit UCS Transformation Format, little-endian byte order
UTF-16          Sixteen-bit UCS Transformation Format, byte order identified by an optional byte-order mark

Reference: http://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html

like image 125
iBabur Avatar answered Oct 06 '22 09:10

iBabur


The charset names in Java are platform dependent, there are only 6 constants in the StandardCharsets class.

To view the all charsets you should look at IANA. Check Preferred MIME Name and aliases columns.

like image 42
telebog Avatar answered Oct 06 '22 08:10

telebog