background image

Character Sets and Encodings

<< Dates and Numbers Formatting | Character Encoding >>
<< Dates and Numbers Formatting | Character Encoding >>

Character Sets and Encodings

The JavaServer Faces version of Duke's Bookstore uses date/time and number converters to
format dates and numbers in a locale-sensitive manner. For example, the same shipping date is
converted in the JavaServer Faces version as follows:
<h:outputText value=
"#{cashier.shipDate}">
<f:convertDateTime dateStyle=
"full"/>
</h:outputText>
For information on JavaServer Faces converters, see
"Using the Standard Converters" on
page 354
.
Character Sets and Encodings
The following sections describe character sets and character encodings.
Character Sets
A character set is a set of textual and graphic symbols, each of which is mapped to a set of
nonnegative integers.
The first character set used in computing was US-ASCII. It is limited in that it can represent
only American English. US-ASCII contains uppercase and lowercase Latin alphabets,
numerals, punctuation, a set of control codes, and a few miscellaneous symbols.
Unicode defines a standardized, universal character set that can be extended to accommodate
additions. When the Java program source file encoding doesn't support Unicode, you can
represent Unicode characters as escape sequences by using the notation \uXXXX, where XXXX
is the character's 16-bit representation in hexadecimal. For example, the Spanish version of the
Duke's Bookstore message file uses Unicode for non-ASCII characters:
{
"TitleCashier", "Cajero"},
{
"TitleBookDescription", "Descripci" + "\u00f3" + "n del
Libro
"},
{
"Visitor", "El visitante" + "\u00fa" + "mero "},
{
"What", "Qu" + "\u00e9" + " libros leemos"},
{
"Talk", " describe cómo los componentes de software de web
pueden transformar la manera en que desarrollamos las
aplicaciones para la web. Este libro es obligatorio para
cualquier programador de respeto!
"},
{
"Start", "Empezar a Comprar"},
Character Sets and Encodings
The Java EE 5 Tutorial · September 2007
472