Bidirectional Conversions
RWUConversionContext combines the functionality provided by RWUToUnicodeConversionContext and RWUFromUnicodeConversionContext to provide a single convenient means for specifying the encoding for conversions to and from Unicode. For example:
 
RWUConversionContext context("ISO-8859-1");
RWUString str("hello");
std::cout << str << std::endl;
RWUConversionContext manages both the to-Unicode and from-Unicode conversion context stacks described in The Conversion Context Stacks.
As with all conversion contexts, you can create an RWUConversionContext within any local scope. When an RWUConversionContext instance goes out of scope, it is destroyed, and destroying the instance automatically pops it off the current thread’s to-Unicode and from-Unicode stacks.
Do not create unnamed, temporary instances of RWUConversionContext. The destructors for such objects pop the context off the context stacks immediately. For example, although this code would compile, it may not have the intended effect:
 
RWUConversionContext("Shift-JIS"); // Wrong!
std::cout << str << std::endl;
NOTE: Do not create unnamed, temporary instances of RWUConversionContext.
Note that RWUConversionContext derives from both RWUToUnicodeConversionContext and RWUFromUnicodeConversionContext, so if you want to call either of the inherited getConverter() methods to return a reference to one of the underlying converters, you must disambiguate them. For example, the following code sets the escape sequence for the underlying RWUFromUnicodeConverter instance:
 
RWUConversionContext context("Shift-JIS");
context.RWUFromUnicodeConverter::getConverter().setErrorResponse(
RWUFromUnicodeConverter::EscapeNativeHexadecimal);
 
std::cout << str << std::endl;