Files
2025-10-25 03:02:53 +03:00

3.6 KiB

[locale.codecvt.general]

28 Text processing library [text]

28.3 Localization library [localization]

28.3.4 Standard locale categories [locale.categories]

28.3.4.2 The ctype category [category.ctype]

28.3.4.2.5 Class template codecvt [locale.codecvt]

28.3.4.2.5.1 General [locale.codecvt.general]

🔗

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

#

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.

2

#

The stateT argument selects the pair of character encodings being mapped between.

3

#

The specializations required in Table 91 ([locale.category]) convert the implementation-defined native character set.

codecvt<char, char, mbstate_t> implements a degenerate conversion; it does not convert at all.

codecvt<wchar_t, char, mbstate_t> converts between the native character sets for ordinary and wide characters.

Specializations on mbstate_t perform conversion between encodings known to the library implementer.

Other encodings can be converted by specializing on a program-defined stateT type.

Objects of type stateT can contain any state that is useful to communicate to or from the specialized do_in or do_out members.