Unicode Tutorials - Herong's Tutorial Examples - v5.32, by Herong Yang
Examples of CP1252 and ISO-8859-1 Encodings
This section provides examples of encoded byte sequences of the JVM default encoding, CP1252 encoding, on a Windows system. The ISO-8859-1 encoding is slightly different that the CP1252 encoding.
Running the testing program with Java 11, EncodingSampler2.java, provided in the previous section without any argument will use the JVM's default character encoding:
C:\herong>javac EncodingSampler2.java C:\herong>java EncodingSampler2 Default (Cp1252) encoding: Char, String, Writer, Charset, Encoder 00000000, 00, 00, 00, 00 0000003F, 3F, 3F, 3F, 3F 00000040, 40, 40, 40, 40 0000007F, 7F, 7F, 7F, 7F 00000080, 3F, 3F, 3F, 00 000000BF, BF, BF, BF, BF 000000C0, C0, C0, C0, C0 000000FF, FF, FF, FF, FF 00000100, 3F, 3F, 3F, 00 00003FFF, 3F, 3F, 3F, 00 00004000, 3F, 3F, 3F, 00 00007FFF, 3F, 3F, 3F, 00 00008000, 3F, 3F, 3F, 00 0000BFFF, 3F, 3F, 3F, 00 0000C000, 3F, 3F, 3F, 00 0000EFFF, 3F, 3F, 3F, 00 0000F000, 3F, 3F, 3F, 00 0000FFFF, 3F, 3F, 3F, 00 0001F108, 3F, 3F, 3F, 00 0001F132, 3F, 3F, 3F, 00 0001F1A0, 3F, 3F, 3F, 00
The results shows that:
Running the program again with 'CP1252' as the argument should give us the same output as the previous run:
C:\herong>java EncodingSampler2 CP1252 CP1252 encoding: Char, String, Writer, Charset, Encoder 00000000, 00, 00, 00, 00 0000003F, 3F, 3F, 3F, 3F 00000040, 40, 40, 40, 40 0000007F, 7F, 7F, 7F, 7F 00000080, 3F, 3F, 3F, 00 000000BF, BF, BF, BF, BF 000000C0, C0, C0, C0, C0 000000FF, FF, FF, FF, FF 00000100, 3F, 3F, 3F, 00 00003FFF, 3F, 3F, 3F, 00 00004000, 3F, 3F, 3F, 00 00007FFF, 3F, 3F, 3F, 00 00008000, 3F, 3F, 3F, 00 0000BFFF, 3F, 3F, 3F, 00 0000C000, 3F, 3F, 3F, 00 0000EFFF, 3F, 3F, 3F, 00 0000F000, 3F, 3F, 3F, 00 0000FFFF, 3F, 3F, 3F, 00 0001F108, 3F, 3F, 3F, 00 0001F132, 3F, 3F, 3F, 00 0001F1A0, 3F, 3F, 3F, 00
Let's try another encoding, ISO-8859-1:
C:\herong>java EncodingSampler2 ISO-8859-1 ISO-8859-1 encoding: Char, String, Writer, Charset, Encoder ISO-8859-1 encoding: Char, String, Writer, Charset, Encoder 00000000, 00, 00, 00, 00 0000003F, 3F, 3F, 3F, 3F 00000040, 40, 40, 40, 40 0000007F, 7F, 7F, 7F, 7F 00000080, 80, 80, 80, 80 000000BF, BF, BF, BF, BF 000000C0, C0, C0, C0, C0 000000FF, FF, FF, FF, FF 00000100, 3F, 3F, 3F, 00 00003FFF, 3F, 3F, 3F, 00 00004000, 3F, 3F, 3F, 00 00007FFF, 3F, 3F, 3F, 00 00008000, 3F, 3F, 3F, 00 0000BFFF, 3F, 3F, 3F, 00 0000C000, 3F, 3F, 3F, 00 0000EFFF, 3F, 3F, 3F, 00 0000F000, 3F, 3F, 3F, 00 0000FFFF, 3F, 3F, 3F, 00 0001F108, 3F, 3F, 3F, 00 0001F132, 3F, 3F, 3F, 00 0001F1A0, 3F, 3F, 3F, 00
ISO-8859-1 encoding is different than CP1252 encoding. As you can see in the output, 0x80 is a valid character in the ISO-8859-1 character set, but not valid in the CP1252 character set.
Table of Contents
ASCII Character Set and Encoding
GB2312 Character Set and Encoding
GB18030 Character Set and Encoding
JIS X0208 Character Set and Encodings
UTF-8 (Unicode Transformation Format - 8-Bit)
UTF-16, UTF-16BE and UTF-16LE Encodings
UTF-32, UTF-32BE and UTF-32LE Encodings
Python Language and Unicode Characters
Java Language and Unicode Characters
List of Supported Character Encodings in Java
EncodingSampler.java - Testing encode() Methods
►Examples of CP1252 and ISO-8859-1 Encodings
Examples of US-ASCII, UTF-8, UTF-16 and UTF-32 Encodings
Encoding Conversion Programs for Encoded Text Files
Using Notepad as a Unicode Text Editor
Using Microsoft Word as a Unicode Text Editor