Converting from Unicode
RWUString provides the toBytes() method that accepts an RWUFromUnicodeConverter instance, and returns an RWCString containing the byte sequence produced when the contents of the RWUString are converted into the specified encoding. For example, assuming source is an RWUString:
 
RWUFromUnicodeConverter toShiftJis("Shift-JIS");
RWCString target = source.toBytes(toShiftJis);
The new RWCString target contains bytes representing characters encoded in Shift-JIS.
RWUString instances can also be converted implicitly by specifying a default conversion context and calling toBytes() with no arguments. For example:
 
RWUFromUnicodeConversionContext toShiftJisContext("Shift-JIS");
RWCString target = source.toBytes();
The stream insertion operator for RWUString also performs conversions. It writes the sequence of bytes that are produced when the contents of a string are converted into the encoding specified by the currently active RWUFromUnicodeConversionContext. For example, assuming str is an RWUString:
 
RWUFromUnicodeConversionContext toShiftJisContext("Shift-JIS");
std::cout << str << std::endl;
See Chapter 4 for more information on conversion.