2 /** Several code conversions facets.
4 E.g. this is how to convert UCS-2 to UTF-8
7 wifstream ifs("input", ios_base::binary);
8 wofstream ofs("output", ios_base::binary);
10 ifs.rdbuf()->pubimbue(locale(locale(), new ucs2_conversion()));
11 ofs.rbbuf()->pubimbue(locale(locale(), new utf8_conversion()));
15 @author Vladimir Prus <ghost@cs.msu.su>
22 /** Conversion facet that allows to use Unicode files in UCS-2 encoding */
24 : public std::codecvt
<wchar_t, char, std::mbstate_t>
28 result
do_in(std::mbstate_t& state
,
29 const char* from
, const char* from_end
, const char*& from_next
,
30 wchar_t* to
, wchar_t* to_limit
, wchar_t*& to_next
) const;
32 result
do_out(std::mbstate_t& state
,
33 const wchar_t* from
, const wchar_t* from_end
, const wchar_t*& from_next
,
34 char* to
, char* to_limit
, char*& to_next
) const;
36 bool do_always_noconv() const throw() { return false; }
37 int do_encoding() const throw() { return 2; }
41 /** Conversion facet that allows to read Unicode files in UTF-8 encoding */
43 : public std::codecvt
<wchar_t, char, std::mbstate_t>
47 result
do_in(std::mbstate_t& state
,
48 const char* from
, const char* from_end
, const char*& from_next
,
49 wchar_t* to
, wchar_t* to_limit
, wchar_t*& to_next
) const;
51 result
do_out(std::mbstate_t& state
,
52 const wchar_t* from
, const wchar_t* from_end
, const wchar_t*& from_next
,
53 char* to
, char* to_limit
, char*& to_next
) const;
55 bool do_always_noconv() const throw() { return false; }
56 int do_encoding() const throw() { return 2; }