2012-09-23 6 views
5

Ich habe eine Frage zu Charset.forName (String charsetName). Gibt es eine Liste von charsetNames, auf die ich mich beziehen kann? Zum Beispiel für UTF-8 verwenden wir „UTF-8“ für die charsetName. Was ist mit WINDOWS-1252, GB18030 usw.?Encoding CharsetNames für Charset.forName (String)

+2

http://docs.oracle.com/javase/6/docs/technotes/guides/intl/encoding.doc.html und die neuesten http://download.java.net/jdk8/docs/technotes/guides /intl/encoding.doc.html – nullpotent

+0

auch gibt es eine gute Diskussion bei http://stackoverflow.com/questions/1684040/java-why-charset-names-are-not-constants –

Antwort

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 

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

2

Die charset Namen in Java sind plattformabhängig, gibt es nur sechs Konstanten in der StandardCharsets Klasse.

die alle charsets zu sehen, Sie bei IANA aussehen sollte. Überprüfen Sie die Spalten "Bevorzugter MIME-Name" und "Aliase".