Unicode Tutorials - Herong's Tutorial Notes
Dr. Herong Yang, Version 5.00

Testing decode() Methods

This section describes 4 different methods provided in JDK to decode byte sequences back to characters with a given encoding.

There are 4 methods to decode characters:

  • CharsetDecoder.decode()
  • Charset.decode()
  • new String()
  • InputStreamReader.read()

The ways to use those methods are similar to encode methods described in previous sections.

Exercise: Find out what is the default 'Charset' used in the 'String' class.

Sections in This Chapter

What Is Character Encoding?

Supported Character Encodings in JDK 1.4.1

EncodingSampler.java - Testing encode() Methods

Examples of CP1252 and ISO-8859-1 Encodings

Examples of US-ASCII, UTF-8, UTF-16 and UTF-16BE Encodings

Examples of GB18030 Encoding

Testing decode() Methods

Dr. Herong Yang, updated in 2009
Testing decode() Methods