2626 * @since 2.3
2727 */
2828public class Charsets {
29+ //
30+ // This class should only contain Charset instances for required encodings. This guarantees that it will load correctly and
31+ // without delay on all Java platforms.
32+ //
2933
3034 /**
3135 * Returns the given Charset or the default Charset if the given Charset is null.
3236 *
3337 * @param charset
3438 * A charset or null.
3539 * @return the given Charset or the default Charset if the given Charset is null
36- * @since 2.3
3740 */
3841 public static Charset toCharset (Charset charset ) {
3942 return charset == null ? Charset .defaultCharset () : charset ;
@@ -47,10 +50,79 @@ public static Charset toCharset(Charset charset) {
4750 * @return a Charset for the named charset
4851 * @throws UnsupportedCharsetException
4952 * If the named charset is unavailable
50- * @since 2.3
5153 */
5254 public static Charset toCharset (String charset ) {
5355 return charset == null ? Charset .defaultCharset () : Charset .forName (charset );
5456 }
5557
58+ /**
59+ * CharEncodingISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1. </p>
60+ * <p>
61+ * Every implementation of the Java platform is required to support this character encoding.
62+ * </p>
63+ *
64+ * @see <a href="http://docs.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
65+ */
66+ public static final Charset ISO_8859_1 = Charset .forName ("ISO-8859-1" );
67+
68+ /**
69+ * <p>
70+ * Seven-bit ASCII, also known as ISO646-US, also known as the Basic Latin block of the Unicode character set.
71+ * </p>
72+ * <p>
73+ * Every implementation of the Java platform is required to support this character encoding.
74+ * </p>
75+ *
76+ * @see <a href="http://docs.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
77+ */
78+ public static final Charset US_ASCII = Charset .forName ("US-ASCII" );
79+
80+ /**
81+ * <p>
82+ * Sixteen-bit Unicode Transformation Format, The byte order specified by a mandatory initial byte-order mark
83+ * (either order accepted on input, big-endian used on output)
84+ * </p>
85+ * <p>
86+ * Every implementation of the Java platform is required to support this character encoding.
87+ * </p>
88+ *
89+ * @see <a href="http://docs.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
90+ */
91+ public static final Charset UTF_16 = Charset .forName ("UTF-16" );
92+
93+ /**
94+ * <p>
95+ * Sixteen-bit Unicode Transformation Format, big-endian byte order.
96+ * </p>
97+ * <p>
98+ * Every implementation of the Java platform is required to support this character encoding.
99+ * </p>
100+ *
101+ * @see <a href="http://docs.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
102+ */
103+ public static final Charset UTF_16BE = Charset .forName ("UTF-16BE" );
104+
105+ /**
106+ * <p>
107+ * Sixteen-bit Unicode Transformation Format, little-endian byte order.
108+ * </p>
109+ * <p>
110+ * Every implementation of the Java platform is required to support this character encoding.
111+ * </p>
112+ *
113+ * @see <a href="http://docs.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
114+ */
115+ public static final Charset UTF_16LE = Charset .forName ("UTF-16LE" );
116+
117+ /**
118+ * <p>
119+ * Eight-bit Unicode Transformation Format.
120+ * </p>
121+ * <p>
122+ * Every implementation of the Java platform is required to support this character encoding.
123+ * </p>
124+ *
125+ * @see <a href="http://docs.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Standard charsets</a>
126+ */
127+ public static final Charset UTF_8 = Charset .forName ("UTF-8" );
56128}
0 commit comments