2012-09-23 10 views
5

Ho una domanda su Charset.forName (String charsetName). C'è una lista di nomi charset a cui posso fare riferimento? Ad esempio, per UTF-8, usiamo "utf8" per charsetName. Che mi dici di WINDOWS-1252, GB18030, ecc.?Codifica CharsetNames per Charset.forName (String)

+2

http://docs.oracle.com/javase/6/docs/technotes/guides/intl/encoding.doc.html e l'ultimo http://download.java.net/jdk8/docs/technotes/guides /intl/encoding.doc.html – nullpotent

+0

Inoltre c'è una buona discussione su http://stackoverflow.com/questions/1684040/java-why-charset-names-are-not-constants –

risposta

5
 
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 

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

2

I nomi charset in Java sono dipendenti dalla piattaforma, ci sono solo 6 costanti nella classe StandardCharsets.

Per visualizzare tutti i set di caratteri, è necessario guardare IANA. Controllare le colonne Nome e alias MIME preferiti.

Problemi correlati