tmp/tmp27mwiu3e/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
##### General <a id="locale.codecvt.general">[[locale.codecvt.general]]</a>
|
| 2 |
+
|
| 3 |
+
``` cpp
|
| 4 |
+
namespace std {
|
| 5 |
+
class codecvt_base {
|
| 6 |
+
public:
|
| 7 |
+
enum result { ok, partial, error, noconv };
|
| 8 |
+
};
|
| 9 |
+
|
| 10 |
+
template<class internT, class externT, class stateT>
|
| 11 |
+
class codecvt : public locale::facet, public codecvt_base {
|
| 12 |
+
public:
|
| 13 |
+
using intern_type = internT;
|
| 14 |
+
using extern_type = externT;
|
| 15 |
+
using state_type = stateT;
|
| 16 |
+
|
| 17 |
+
explicit codecvt(size_t refs = 0);
|
| 18 |
+
|
| 19 |
+
result out(
|
| 20 |
+
stateT& state,
|
| 21 |
+
const internT* from, const internT* from_end, const internT*& from_next,
|
| 22 |
+
externT* to, externT* to_end, externT*& to_next) const;
|
| 23 |
+
|
| 24 |
+
result unshift(
|
| 25 |
+
stateT& state,
|
| 26 |
+
externT* to, externT* to_end, externT*& to_next) const;
|
| 27 |
+
|
| 28 |
+
result in(
|
| 29 |
+
stateT& state,
|
| 30 |
+
const externT* from, const externT* from_end, const externT*& from_next,
|
| 31 |
+
internT* to, internT* to_end, internT*& to_next) const;
|
| 32 |
+
|
| 33 |
+
int encoding() const noexcept;
|
| 34 |
+
bool always_noconv() const noexcept;
|
| 35 |
+
int length(stateT&, const externT* from, const externT* end, size_t max) const;
|
| 36 |
+
int max_length() const noexcept;
|
| 37 |
+
|
| 38 |
+
static locale::id id;
|
| 39 |
+
|
| 40 |
+
protected:
|
| 41 |
+
~codecvt();
|
| 42 |
+
virtual result do_out(
|
| 43 |
+
stateT& state,
|
| 44 |
+
const internT* from, const internT* from_end, const internT*& from_next,
|
| 45 |
+
externT* to, externT* to_end, externT*& to_next) const;
|
| 46 |
+
virtual result do_in(
|
| 47 |
+
stateT& state,
|
| 48 |
+
const externT* from, const externT* from_end, const externT*& from_next,
|
| 49 |
+
internT* to, internT* to_end, internT*& to_next) const;
|
| 50 |
+
virtual result do_unshift(
|
| 51 |
+
stateT& state,
|
| 52 |
+
externT* to, externT* to_end, externT*& to_next) const;
|
| 53 |
+
|
| 54 |
+
virtual int do_encoding() const noexcept;
|
| 55 |
+
virtual bool do_always_noconv() const noexcept;
|
| 56 |
+
virtual int do_length(stateT&, const externT* from, const externT* end, size_t max) const;
|
| 57 |
+
virtual int do_max_length() const noexcept;
|
| 58 |
+
};
|
| 59 |
+
}
|
| 60 |
+
```
|
| 61 |
+
|
| 62 |
+
The class `codecvt<internT, externT, stateT>` is for use when converting
|
| 63 |
+
from one character encoding to another, such as from wide characters to
|
| 64 |
+
multibyte characters or between wide character encodings such as UTF-32
|
| 65 |
+
and EUC.
|
| 66 |
+
|
| 67 |
+
The `stateT` argument selects the pair of character encodings being
|
| 68 |
+
mapped between.
|
| 69 |
+
|
| 70 |
+
The specializations required in [[locale.category.facets]]
|
| 71 |
+
[[locale.category]] convert the implementation-defined native character
|
| 72 |
+
set. `codecvt<char, char, mbstate_t>` implements a degenerate
|
| 73 |
+
conversion; it does not convert at all. The specialization
|
| 74 |
+
`codecvt<char16_t, char8_t, mbstate_t>` converts between the UTF-16 and
|
| 75 |
+
UTF-8 encoding forms, and the specialization
|
| 76 |
+
`codecvt<char32_t, char8_t, mbstate_t>` converts between the UTF-32 and
|
| 77 |
+
UTF-8 encoding forms. `codecvt<wchar_t, char, mbstate_t>` converts
|
| 78 |
+
between the native character sets for ordinary and wide characters.
|
| 79 |
+
Specializations on `mbstate_t` perform conversion between encodings
|
| 80 |
+
known to the library implementer. Other encodings can be converted by
|
| 81 |
+
specializing on a program-defined `stateT` type. Objects of type
|
| 82 |
+
`stateT` can contain any state that is useful to communicate to or from
|
| 83 |
+
the specialized `do_in` or `do_out` members.
|
| 84 |
+
|