Don't move one char to the right before searching for the next target
[TortoiseGit.git] / src / ResText / codecvt.h
blob880ad2c271c86d4e27763e54748d2f85df8a6337
2 /** Several code conversions facets.
4 E.g. this is how to convert UCS-2 to UTF-8
6 @code
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()));
12 ofs << ifs.rdbuf();
13 @endcode
15 @author Vladimir Prus <ghost@cs.msu.su>
17 @file
20 #include <locale>
22 /** Conversion facet that allows to use Unicode files in UCS-2 encoding */
23 class ucs2_conversion
24 : public std::codecvt<wchar_t, char, std::mbstate_t>
26 protected:
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 */
42 class utf8_conversion
43 : public std::codecvt<wchar_t, char, std::mbstate_t>
45 protected:
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; }