Wide/narrow character conversion

Conversion between narrow and wide characters is implemented as an IO filter.

#include <x/locale.H>
#include <x/basicstreamcodecvtobj.H>

std::wostringstream widecharbuf;

x::ctow_ostream::streamref_t o(ctow_ostream::create(widecharbuf, l));

The x::ctow_ostream factory constructs a narrow character output stream, x::ctow_ostream::streamref_t is a subclass of x::ostream, that converts the written characters to wide characters and writes the resulting characters to a std::wostream. The locale for narrow/wide character conversion, and the wide character stream, is passed as arguments to the create() method.

x::wtoc_ostream does the opposite conversion: from wide characters to narrow characters. x::wtoc_ostream::streamref_t is a reference to a wide-character output stream, that converts the written wide characters to narrow characters which are then written to a narrow character output stream.

x::ctow_istream, and x::wtoc_istream implement the conversion as input streams:

#include <x/locale.H>
#include <x/basicstreamcodecvtobj.H>

std::istringstream narrowcharbuf;

x::ctow_istream::streamref_t i(ctow_istream::create(narrowcharbuf, l));

x::ctow_istream::streamref_t is a wide character input stream. Reading from it results in reading narrow characters from the underlying narrow character input stream, which get converted to wide characters using the given locale. The narrow character input stream reference and the locale for the conversion are passed as the arguments to the create() method. x::wtoc_istream::streamref_t is the opposite conversion: it's a narrow character input stream that reads from a wide character input stream.

Finally, x::ctow_iostream combines an input stream and an output stream. x::ctow_iostream is a narrow character stream that reads/writes from a wide character stream. x::wtoc_iostream is a wide character stream that reads/writes from a narrow character stream.