Apache C++ Standard Library User's Guide

## 45.1 The Character Type

You may already have used iostreams in the past -- the traditional iostreams. The iostreams defined in the C++ standard library are mostly compatible, yet slightly different from what you know. The most apparent change is that the new iostream classes are templates, taking the type of the character as a template parameter.

The traditional iostreams were of limited use. They could handle only narrow character streams; in other words, they read files character by character, and worked internally with a buffer of narrow characters. They had problems with languages that have alphabets containing numbers of characters exceeding the number of possible values of type `char`. These alphabets are encoded as multibytes for storage on external devices like files, and represented as wide characters internally. They required a code conversion with each input and output.

The new templatized iostreams can handle large alphabets. These iostreams can be instantiated for narrow characters of type `char`, and for wide characters of type `wchar_t`. In fact, you can instantiate iostream classes for any user-defined character type. Chapter 41 describes in detail how this can be done.