STD::CODECVT(3cxx)
β¨ std::codecvt< _InternT, _ExternT, _StateT >(3cxx) β¨
okay bestie, so this is from the <locale> library manual, and it's literally the std::codecvt page π
it's giving "character set conversion royalty" and honestly? we're obsessed.
πΈ NAME πΈ
std::codecvt< _InternT, _ExternT, _StateT > β the Primary class template codecvt. that's it, that's the vibe π
β¨ SYNOPSIS β¨
#include <locale>
so first things first, it Inherits from std::__codecvt_abstract_base< _InternT, _ExternT, _StateT >. and guess what β it's also Inherited by std::codecvt_byname< _InternT, _ExternT, _StateT >. family tree is giving main character energy fr fr π
π Public Types
typedef _ExternT extern_typeβ the external (think: on-disk, out-in-the-world) character type, slaytypedef _InternT intern_typeβ the internal (think: in-memory, cozy) character typetypedef codecvt_base::result resultβ the result enum it uses, iconictypedef _StateT state_typeβ the conversion state type, periodt
π₯ Public Member Functions
codecvt (__c_locale __cloc, size_t __refs=0)β constructor that takes a C locale and refs, no capcodecvt (size_t __refs=0)β the plain refs-only constructor, lowkey the default onebool always_noconv () const throw ()β tells you if this facet never actually converts anythingint encoding () const throw ()β how many extern chars per intern char (or a fun negative value, k)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. the classic glow-up from extern to intern πint length (state_type &__state, const extern_type *__from, const extern_type *__end, size_t __max) constβ how many chars would actually get converted, ngl it's the vibe check of conversionsint max_length () const throw ()β the max bytes/units a single intern char can ever expand into, big yikes energyresult 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. the reverse glow-up, we love a two-way queen β¨result unshift (state_type &__state, extern_type *__to, extern_type *__to_end, extern_type *&__to_next) constβ Reset conversion state. the cleanup era, we stan a tidy state π§
π Static Public Attributes
static locale::id idβ the locale id, the one and only, iconic as always
π¦ Protected Member Functions
virtual bool do_always_noconv () const throw ()β the overridable version of always_noconv, your fave hookvirtual int do_encoding () const throw ()β the overridable encoding hook, go offvirtual 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) constβ the actual conversion logic forin, this is where the real work happens fr frvirtual int do_length (state_type &, const extern_type *__from, const extern_type *__end, size_t __max) constβ the length override hook, note it doesn't even name the state param, periodtvirtual int do_max_length () const throw ()β max_length override hook, your favevirtual 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. the do_out hook, she's the moment πvirtual result do_unshift (state_type &__state, extern_type *__to, extern_type *__to_end, extern_type *&__to_next) constβ the unshift override hook, reset era part 2
π Static Protected Member Functions
static __c_locale _S_clone_c_locale (__c_locale &__cloc) throw ()β clone a C locale like a lil copy-paste fairy π§static void _S_create_c_locale (__c_locale &__cloc, const char *__s, __c_locale __old=0)β make a C locale from a name, the whole__old=0default is giving safety netstatic void _S_destroy_c_locale (__c_locale &__cloc)β destroy it, goodbye bestie πstatic __c_locale _S_get_c_locale ()β grab the C locale, yasstatic const char * _S_get_c_name () throw ()β get the C locale's name string, iconicstatic __c_locale _S_lc_ctype_c_locale (__c_locale __cloc, const char *__s)β the ctype flavor of c locale stuff, lowkey specific
π Protected Attributes
__c_locale _M_c_locale_codecvtβ the protected C locale member, living her best protected life
π Detailed Description π
template<typename _InternT, typename _ExternT, typename _StateT>
class std::codecvt< _InternT, _ExternT, _StateT >
okay so this is the Primary class template codecvt β and bestie, read the fine print: NB: Generic, mostly useless implementation. π like not me finding out the base template is literally decorative. fr fr though, that's just how it is β the real magic lives in the specializations and the codecvt_byname child. it's giving "placeholder era" but make it β¨ standard-compliant β¨
part 1 of 2, bestie β stay tuned π
π Member Function Documentation π
Okay bestie, this is the function-by-function tea. Every single one is here, no skipping, no cap. β¨
do_always_noconv π
template<typename _InternT , typename _ExternT , typename _StateT > virtual
bool std::codecvt< _InternT, _ExternT, _StateT >::do_always_noconv ()
const [protected], [virtual]
This one is [protected] and [virtual], and it implements std::__codecvt_abstract_base< _InternT, _ExternT, _StateT >. Thatβs literally all the page gives us β no extra lore, no cap.
do_encoding π
template<typename _InternT , typename _ExternT , typename _StateT > virtual
int std::codecvt< _InternT, _ExternT, _StateT >::do_encoding () const
[protected], [virtual]
Also [protected] and [virtual], and it implements std::__codecvt_abstract_base< _InternT, _ExternT, _StateT >. Short and mysterious, periodt.
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]
[protected], [virtual], and it implements std::__codecvt_abstract_base< _InternT, _ExternT, _StateT >. Thatβs the whole vibe for this one.
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]
[protected], [virtual], and it implements std::__codecvt_abstract_base< _InternT, _ExternT, _StateT >. Iconic brevity.
do_max_length β
template<typename _InternT , typename _ExternT , typename _StateT > virtual
int std::codecvt< _InternT, _ExternT, _StateT >::do_max_length () const
[protected], [virtual]
[protected], [virtual], and it implements std::__codecvt_abstract_base< _InternT, _ExternT, _StateT >. Thatβs it, bestie.
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]
[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.
It 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]
[protected], [virtual], and it implements std::__codecvt_abstract_base< _InternT, _ExternT, _StateT >. Another short queen.
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]
[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.
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]
[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
std::__codecvt_abstract_base< _InternT, _ExternT, _StateT >::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]
[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 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.
π Author π
Generated automatically by Doxygen for libstdc++ from the source code.
π Thatβs the whole page, bestie! Source: libstdc++; footer/handle situation: libstdstd::codecvt< ...ernT, _StateT >(3cxx); date: none shown in this copy. Mwah! π
π¦ where this page comes from
- ubuntu noble: libstdc++-14-doc 14-20240412-0ubuntu1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms