68 lines
3.6 KiB
Markdown
68 lines
3.6 KiB
Markdown
[locale.codecvt.general]
|
||
|
||
# 28 Text processing library [[text]](./#text)
|
||
|
||
## 28.3 Localization library [[localization]](localization#locale.codecvt.general)
|
||
|
||
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#locale.codecvt.general)
|
||
|
||
#### 28.3.4.2 The ctype category [[category.ctype]](category.ctype#locale.codecvt.general)
|
||
|
||
#### 28.3.4.2.5 Class template codecvt [[locale.codecvt]](locale.codecvt#general)
|
||
|
||
#### 28.3.4.2.5.1 General [locale.codecvt.general]
|
||
|
||
[ð](#lib:codecvt)
|
||
|
||
namespace std {class codecvt_base {public:enum result { ok, partial, error, noconv }; }; template<class internT, class externT, class stateT>class codecvt : public locale::facet, public codecvt_base {public:using intern_type = internT; using extern_type = externT; using state_type = stateT; explicit codecvt(size_t refs = 0);
|
||
|
||
result out( stateT& state, const internT* from, const internT* from_end, const internT*& from_next,
|
||
externT* to, externT* to_end, externT*& to_next) const;
|
||
|
||
result unshift( stateT& state,
|
||
externT* to, externT* to_end, externT*& to_next) const;
|
||
|
||
result in( stateT& state, const externT* from, const externT* from_end, const externT*& from_next,
|
||
internT* to, internT* to_end, internT*& to_next) const; int encoding() const noexcept; bool always_noconv() const noexcept; int length(stateT&, const externT* from, const externT* end, size_t max) const; int max_length() const noexcept; static locale::id id; protected:~codecvt(); virtual result do_out( stateT& state, const internT* from, const internT* from_end, const internT*& from_next,
|
||
externT* to, externT* to_end, externT*& to_next) const; virtual result do_in( stateT& state, const externT* from, const externT* from_end, const externT*& from_next,
|
||
internT* to, internT* to_end, internT*& to_next) const; virtual result do_unshift( stateT& state,
|
||
externT* to, externT* to_end, externT*& to_next) const; virtual int do_encoding() const noexcept; virtual bool do_always_noconv() const noexcept; virtual int do_length(stateT&, const externT* from, const externT* end, size_t max) const; virtual int do_max_length() const noexcept; };}
|
||
|
||
[1](#1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2017)
|
||
|
||
The class codecvt<internT, externT, stateT> is for use
|
||
when converting from one character encoding to another,
|
||
such as from wide characters to multibyte characters or
|
||
between wide character encodings such as UTF-32 and EUC[.](#1.sentence-1)
|
||
|
||
[2](#2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2023)
|
||
|
||
The stateT argument selects
|
||
the pair of character encodings being mapped between[.](#2.sentence-1)
|
||
|
||
[3](#3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L2027)
|
||
|
||
The specializations required
|
||
in Table [91](locale.category#tab:locale.category.facets "Table 91: Locale category facets") ([[locale.category]](locale.category "28.3.3.1.2.1 Type locale::category"))
|
||
convert the implementation-defined native character set[.](#3.sentence-1)
|
||
|
||
codecvt<char, char, mbstate_t> implements a degenerate conversion;
|
||
it does not convert at all[.](#3.sentence-2)
|
||
|
||
codecvt<wchar_t, char, mbstate_t> converts between the native character sets for ordinary and wide characters[.](#3.sentence-3)
|
||
|
||
Specializations on mbstate_t perform conversion between encodings known to the library implementer[.](#3.sentence-4)
|
||
|
||
Other encodings can be converted by specializing on
|
||
a program-defined stateT type[.](#3.sentence-5)
|
||
|
||
Objects of type stateT can contain any state
|
||
that is useful to communicate to or from
|
||
the specialized do_in or do_out members[.](#3.sentence-6)
|