STD::CODECVT(3)
π std::codecvt< _InternT, _ExternT, _StateT > π
okay bestie, welcome to section 3 of the Library Functions Manual, and today's main character is std::codecvt< _InternT, _ExternT, _StateT >, aka the Primary class template codecvt. it's giving character-set-conversion royalty. it's giving bridge between how your program thinks about text and how the outside world writes it down. β¨
πΈ NAME πΈ
std::codecvt< _InternT, _ExternT, _StateT > β the Primary class template codecvt. literally what it says on the tin, no cap.
π¦ SYNOPSIS π¦
#include <locale>
Inherits from std::__codecvt_abstract_base< _InternT, _ExternT, _StateT >.
Inherited by std::codecvt_byname< _InternT, _ExternT, _StateT >.
π Public Types π
typedef _ExternT extern_typetypedef _InternT intern_typetypedef codecvt_base::result resulttypedef _StateT state_type
π Public Member Functions π
codecvt (__c_locale __cloc, size_t __refs=0)β the constructor that takes a C locale.codecvt (size_t __refs=0)β the plain constructor, takes just the refs count.bool always_noconv () const throw ()β tells you whether this facet never needs to convert anything at all.int encoding () const throw ()β the encoding situation.result in (state_type &__state, const extern_type *__from, const extern_type *__from_end, const extern_type *&__from_next, intern_type *__to, intern_type *__to_end, intern_type *&__to_next) constβ Convert from external to internal character set.int length (state_type &__state, const extern_type *__from, const extern_type *__end, size_t __max) constβ how long a conversion run actually goes.int max_length () const throw ()β the maximum length you might get.result out (state_type &__state, const intern_type *__from, const intern_type *__from_end, const intern_type *&__from_next, extern_type *__to, extern_type *__to_end, extern_type *&__to_next) constβ Convert from internal to external character set.result unshift (state_type &__state, extern_type *__to, extern_type *__to_end, extern_type *&__to_next) constβ Reset conversion state.
β Static Public Attributes β
static locale::id idβ the facet's one and only id. iconic, singular, irreplaceable.
π Protected Member Functions π
virtual bool do_always_noconv () const throw ()virtual int do_encoding () const throw ()virtual result do_in (state_type &__state, const extern_type *__from, const extern_type *__from_end, const extern_type *&__from_next, intern_type *__to, intern_type *__to_end, intern_type *&__to_next) constvirtual int do_length (state_type &, const extern_type *__from, const extern_type *__end, size_t __max) constvirtual int do_max_length () const throw ()virtual result do_out (state_type &__state, const intern_type *__from, const intern_type *__from_end, const intern_type *&__from_next, extern_type *__to, extern_type *__to_end, extern_type *&__to_next) constβ Convert from internal to external character set.virtual result do_unshift (state_type &__state, extern_type *__to, extern_type *__to_end, extern_type *&__to_next) const
π§ Static Protected Member Functions π§
static __c_locale _S_clone_c_locale (__c_locale &__cloc) throw ()static void _S_create_c_locale (__c_locale &__cloc, const char *__s, __c_locale __old=0)static void _S_destroy_c_locale (__c_locale &__cloc)static __c_locale _S_get_c_locale ()static const char * _S_get_c_name () throw ()static __c_locale _S_lc_ctype_c_locale (__c_locale __cloc, const char *__s)
π Protected Attributes π
__c_locale _M_c_locale_codecvt
β¨ Detailed Description β¨
template<typename _InternT, typename _ExternT, typename _StateT>
class std::codecvt< _InternT, _ExternT, _StateT >
"Primary class template codecvt."
NB: Generic, mostly useless implementation. π« like bestie, it exists, it compiles, it does approximately nothing interesting. the real work gets done by the specializations and the derived classes, iykyk.
π₯ Member Function Documentation π₯
do_always_noconv
template<typename _InternT, typename _ExternT, typename _StateT> virtual
bool std::codecvt< _InternT, _ExternT, _StateT >::do_always_noconv ()
const [protected], [virtual]
Implements std::__codecvt_abstract_base< _InternT, _ExternT, _StateT >.
do_encoding
template<typename _InternT, typename _ExternT, typename _StateT> virtual int
std::codecvt< _InternT, _ExternT, _StateT >::do_encoding () const
[protected], [virtual]
Implements std::__codecvt_abstract_base< _InternT, _ExternT, _StateT >.
do_in
template<typename _InternT, typename _ExternT, typename _StateT> virtual
result std::codecvt< _InternT, _ExternT, _StateT >::do_in (state_type &
__state, const extern_type * __from, const extern_type * __from_end,
const extern_type *& __from_next, intern_type * __to, intern_type *
__to_end, intern_type *& __to_next) const [protected], [virtual]
Implements std::__codecvt_abstract_base< _InternT, _ExternT, _StateT >.
do_length
template<typename _InternT, typename _ExternT, typename _StateT> virtual int
std::codecvt< _InternT, _ExternT, _StateT >::do_length (state_type & ,
const extern_type * __from, const extern_type * __end, size_t __max)
const [protected], [virtual]
Implements std::__codecvt_abstract_base< _InternT, _ExternT, _StateT >.
do_max_length
template<typename _InternT, typename _ExternT, typename _StateT> virtual int
std::codecvt< _InternT, _ExternT, _StateT >::do_max_length () const
[protected], [virtual]
Implements std::__codecvt_abstract_base< _InternT, _ExternT, _StateT >.
do_out
template<typename _InternT, typename _ExternT, typename _StateT> virtual
result std::codecvt< _InternT, _ExternT, _StateT >::do_out (state_type &
__state, const intern_type * __from, const intern_type * __from_end,
const intern_type *& __from_next, extern_type * __to, extern_type *
__to_end, extern_type *& __to_next) const [protected], [virtual]
Convert from internal to external character set. Converts input string of intern_type to output string of extern_type. This function is a hook for derived classes to change the value returned.
See also out for more information.
Implements std::__codecvt_abstract_base< _InternT, _ExternT, _StateT >.
do_unshift
template<typename _InternT, typename _ExternT, typename _StateT> virtual
result std::codecvt< _InternT, _ExternT, _StateT >::do_unshift
(state_type & __state, extern_type * __to, extern_type * __to_end,
extern_type *& __to_next) const [protected], [virtual]
Implements std::__codecvt_abstract_base< _InternT, _ExternT, _StateT >.
in
template<typename _InternT, typename _ExternT, typename _StateT> result
std::__codecvt_abstract_base< _InternT, _ExternT, _StateT >::in
(state_type & __state, const extern_type * __from, const extern_type *
__from_end, const extern_type *& __from_next, intern_type * __to,
intern_type * __to_end, intern_type *& __to_next) const [inline],
[inherited]
Convert from external to internal character set. π« Converts input string of extern_type to output string of intern_type. This is analogous to mbsrtowcs. It does this by calling codecvt::do_in.
The source and destination character sets are determined by the facet's locale, internal and external types.
The characters in [from,from_end) are converted and written to [to,to_end). from_next and to_next are set to point to the character following the last successfully converted character, respectively. If the result needed no conversion, from_next and to_next are not affected.
The state argument should be initialized if the input is at the beginning and carried from a previous call if continuing conversion. There are no guarantees about how state is used.
β οΈ no promises about how state gets used, bestie. it's giving "trust the process".
The result returned is a member of codecvt_base::result. If all the input is converted, returns codecvt_base::ok. If no conversion is necessary, returns codecvt_base::noconv. If the input ends early or there is insufficient space in the output, returns codecvt_base::partial. Otherwise the conversion failed and codecvt_base::error is returned.
Parameters
__stateβ Persistent conversion state data.__fromβ Start of input.__from_endβ End of input.__from_nextβ Returns start of unconverted data.__toβ Start of output buffer.__to_endβ End of output buffer.__to_nextβ Returns start of unused output area.
Returns
codecvt_base::result.
out
template<typename _InternT, typename _ExternT, typename _StateT> result
std::__codecvt_abstract_base< _InternT, _ExternT, _StateT >::out
(state_type & __state, const intern_type * __from, const intern_type *
__from_end, const intern_type *& __from_next, extern_type * __to,
extern_type * __to_end, extern_type *& __to_next) const [inline],
[inherited]
Convert from internal to external character set. π Converts input string of intern_type to output string of extern_type. This is analogous to wcsrtombs. It does this by calling codecvt::do_out.
The source and destination character sets are determined by the facet's locale, internal and external types.
The characters in [from,from_end) are converted and written to [to,to_end). from_next and to_next are set to point to the character following the last successfully converted character, respectively. If the result needed no conversion, from_next and to_next are not affected.
The state argument should be initialized if the input is at the beginning and carried from a previous call if continuing conversion. There are no guarantees about how state is used.
The result returned is a member of codecvt_base::result. If all the input is converted, returns codecvt_base::ok. If no conversion is necessary, returns codecvt_base::noconv. If the input ends early or there is insufficient space in the output, returns codecvt_base::partial. Otherwise the conversion failed and codecvt_base::error is returned.
Parameters
__stateβ Persistent conversion state data.__fromβ Start of input.__from_endβ End of input.__from_nextβ Returns start of unconverted data.__toβ Start of output buffer.__to_endβ End of output buffer.__to_nextβ Returns start of unused output area.
Returns
codecvt_base::result.
References do_out().
unshift
template<typename _InternT, typename _ExternT, typename _StateT> result
std::__codecvt_abstract_base< _InternT, _ExternT, _StateT >::unshift
(state_type & __state, extern_type * __to, extern_type * __to_end,
extern_type *& __to_next) const [inline], [inherited]
Reset conversion state. π§Ό Writes characters to output that would restore state to initial conditions. The idea is that if a partial conversion occurs, then the converting the characters written by this function would leave the state in initial conditions, rather than partial conversion state. It does this by calling codecvt::do_unshift().
For example, if 4 external characters always converted to 1 internal character, and input to in() had 6 external characters with state saved, this function would write two characters to the output and set the state to initialized conditions.
The source and destination character sets are determined by the facet's locale, internal and external types.
The result returned is a member of codecvt_base::result. If the state could be reset and data written, returns codecvt_base::ok. If no conversion is necessary, returns codecvt_base::noconv. If the output has insufficient space, returns codecvt_base::partial. Otherwise the reset failed and codecvt_base::error is returned.
Parameters
__stateβ Persistent conversion state data.__toβ Start of output buffer.__to_endβ End of output buffer.__to_nextβ Returns start of unused output area.
Returns
codecvt_base::result.
to be continued, bestie π part 2 is loadingβ¦
β¨ Author π
Okay so plot twist bestie β no human wrote this. π
This whole page was Generated automatically by Doxygen for libstdc++ from the source code.
Like, it's literally giving robot-authored, machine-generated, nobody's-personal-takes energy. π¦ Doxygen looked at the actual libstdc++ source code and went "say less" and produced this entire man page by itself. No cap.
So there's no author to hype up here, no @ to give credit to, no main character with a GitHub handle. π Just Doxygen doing its thing for libstdc++, faithfully, every single time the docs get rebuilt. Respect honestly. π
π And that's a wrap on this page! Brought to you bylibstdc++β this one'sstd::codecvt<..., _StateT>(3), straight from the library's own manual, no date on the footer so we're just vibing with the version tag it gave us. π«Ά Go read the source, it's right there, iykyk. β¨πΈ
π¦ where this page comes from
- arch rolling: gcc 16.2.1+r23+gd564253eb6c8-1 Β· GPL-3.0-or-later WITH GCC-exception-3.1 AND GFDL-1.3-or-later
- centos-stream 10: gcc-toolset-15-libstdc++-docs 15.2.1-8.1.el10 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- centos-stream 10: gcc-toolset-16-libstdc++-docs 16.2.1-1.3.el10 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- centos-stream 10: libstdc++-docs 14.4.1-4.el10 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- fedora 43: libstdc++-docs 15.2.1-2.fc43 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- fedora 43: libstdc++-docs 15.3.1-1.fc43 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- fedora 44: libstdc++-docs 16.0.1-0.10.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- fedora 44: libstdc++-docs 16.2.1-2.fc44
- fedora 44: libstdc++-docs 16.2.1-3.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms