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 #pragma warning(disable: 4511)
23 #pragma warning(disable: 4512)
25 /** Conversion facet that allows to use Unicode files in UCS-2 encoding */
27 : public std::codecvt
<wchar_t, char, std::mbstate_t>
31 result
do_in(std::mbstate_t& state
,
32 const char* from
, const char* from_end
, const char*& from_next
,
33 wchar_t* to
, wchar_t* to_limit
, wchar_t*& to_next
) const;
35 result
do_out(std::mbstate_t& state
,
36 const wchar_t* from
, const wchar_t* from_end
, const wchar_t*& from_next
,
37 char* to
, char* to_limit
, char*& to_next
) const;
39 bool do_always_noconv() const throw() { return false; }
40 int do_encoding() const throw() { return 2; }
44 /** Conversion facet that allows to read Unicode files in UTF-8 encoding */
46 : public std::codecvt
<wchar_t, char, std::mbstate_t>
50 result
do_in(std::mbstate_t& state
,
51 const char* from
, const char* from_end
, const char*& from_next
,
52 wchar_t* to
, wchar_t* to_limit
, wchar_t*& to_next
) const;
54 result
do_out(std::mbstate_t& state
,
55 const wchar_t* from
, const wchar_t* from_end
, const wchar_t*& from_next
,
56 char* to
, char* to_limit
, char*& to_next
) const;
58 bool do_always_noconv() const throw() { return false; }
59 int do_encoding() const throw() { return 2; }