In the past, the C++ classic stream libraries enabled input and output of char
s. Because a char
normally occupies one byte, it can represent only a limited set of characters (such as those in the ASCII character set used by most readers of this book, or other popular character sets). However, many languages use alphabets that contain more characters than a single-byte char
can represent. The ASCII character set does not provide these characters; the Unicode® character set does. Unicode is an extensive international character set that represents the majority of the world’s “commercially viable” languages, mathematical symbols and much more. For more information on Unicode, visit www.unicode.org
.
C++ includes the standard stream libraries, which enable developers to build systems capable of performing I/O operations with Unicode characters. For this purpose, C++ includes the type wchar_t, which among other uses can store Unicode characters. The C++ standard also redesigned the classic C++ stream classes, which processed only char
s, as class templates with specializations for processing characters of types char
and wchar_t
, respectively. We use the char
specializations. The size of type wchar_t
is not specified by the standard. C++11’s new char16_t
and char32_t
types for representing Unicode characters were added to provide character types with explicitly specified sizes.