
An example of when a you would want to imbue a new locale on a stream might be the case where a file has a header that requires a different code conversion facet. The following code imbues the JIS to UNICODE conversion facet from Chapter 19 onto a stream, reads a single line, then imbues the default locale to continue processing the file:
wstring header;
wstring body;
typedef basic_ifstream<wchar_t,JIS_char_traits> JIS_ifstream; //1
JIS_fstream in("special.txt");
UnicodeJISConversion<wchar_t,char,JISstate_t> cvtfac;
locale cvtloc(locale(),&cvtfac);
in.rdbuf()->pubimbue(cvtloc) //2
getline(in,header);
in.rdbuf()->pubimbue(locale());
in >> body;
©Copyright 1998, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.