STD::CODECVT_BYNAME(3cxx)
πΈ NAME πΈ
Okay bestie, this is the (3cxx) manual page for std::codecvt_byname< _InternT, _ExternT, _StateT > β and she is literally a class: codecvt_byname [22.2.1.6]. Locale vibes, no cap. π
β¨ SYNOPSIS β¨
#include <locale>
Inherits std::codecvt< _InternT, _ExternT, _StateT >.
π Public Types π
typedef _ExternT extern_typetypedef _InternT intern_typetypedef codecvt_base::result resulttypedef _StateT state_type
π Public Member Functions π
Hereβs the whole roster, bestie:
- Constructor from a C string:
codecvt_byname (const char *__s, size_t __refs=0)
- Constructor from a
string:
codecvt_byname (const string &__s, size_t __refs=0)
bool always_noconv () const throw ()β asks the always-no-conversion question, iconic.int encoding () const throw ()β encoding info, iykyk.result inβ Convert from external to internal character set.
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
int lengthβ length check energy:
int length (state_type &__state, const extern_type *__from, const
extern_type *__end, size_t __max) const
int max_length () const throw ()β max length, periodt.result outβ Convert from internal to external character set.
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
result unshiftβ Reset conversion state.
result unshift (state_type &__state, extern_type *__to, extern_type
*__to_end, extern_type *&__to_next) const
β Static Public Attributes β
static locale::id idβ the static public attribute, main character energy. β
π§ Protected Member Functions π§
These are the protected virtual cuties, bestie:
virtual bool do_always_noconv () const throw ()virtual int do_encoding () const throw ()virtual result do_inβ signature:
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)
const
virtual int do_lengthβ signature:
virtual int do_length (state_type &, const extern_type *__from, const
extern_type *__end, size_t __max) const
virtual int do_max_length () const throw ()virtual result do_outβ Convert from internal to external character set.
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
virtual result do_unshiftβ signature:
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β protected attribute, keeping it cozy. π
π Detailed Description π
template<typename _InternT, typename _ExternT, typename _StateT>
class std::codecvt_byname< _InternT, _ExternT, _StateT >"class
codecvt_byname [22.2.1.6].
π Member Function Documentation π
okay bestie this is the part where we go through every single one of these bad boys one by one, no skipping, no "you get the idea" β we're doing all of them fr fr π«Ά
πΈ do_always_noconv
template<typename _InternT , typename _ExternT , typename _StateT > virtual
bool std::codecvt< _InternT, _ExternT, _StateT >::do_always_noconv ()
const [protected], [virtual], [inherited]
Implements std::__codecvt_abstract_base< _InternT, _ExternT, _StateT >.
Note the vibe check: it's [protected], [virtual], and [inherited] β inherited from the abstract base, protected so you can't just poke it from outside, and virtual so derived classes can do their own thing. β¨
πΈ do_encoding
template<typename _InternT , typename _ExternT , typename _StateT > virtual
int std::codecvt< _InternT, _ExternT, _StateT >::do_encoding () const
[protected], [virtual], [inherited]
Implements std::__codecvt_abstract_base< _InternT, _ExternT, _StateT >.
Same trio of tags β [protected], [virtual], [inherited]. Short and sweet, we love a lowkey function π
πΈ 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],
[inherited]
Implements std::__codecvt_abstract_base< _InternT, _ExternT, _StateT >.
That's the one that does the actual external β internal conversion work, and yeah, it's [protected], [virtual], [inherited] too. If you actually want to call something, you want in β keep reading, bestie, it's coming π
πΈ 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], [inherited]
Implements std::__codecvt_abstract_base< _InternT, _ExternT, _StateT >.
Yup β [protected], [virtual], [inherited]. Also notice the state parameter is just state_type & with no name, that's not me being lazy, that's literally how it's written. Periodt.
πΈ do_max_length
template<typename _InternT , typename _ExternT , typename _StateT > virtual
int std::codecvt< _InternT, _ExternT, _StateT >::do_max_length () const
[protected], [virtual], [inherited]
Implements std::__codecvt_abstract_base< _InternT, _ExternT, _StateT >.
[protected], [virtual], [inherited]. That's it, that's the whole thing π
π₯ 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],
[inherited]
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 >.
So like β do_out is the pluggable hook, out is the public one you actually call. Two different girls, same energy β¨
πΈ 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], [inherited]
Implements std::__codecvt_abstract_base< _InternT, _ExternT, _StateT >.
Tagged [protected], [virtual], [inherited] β and again, the public-facing version is unshift, keep scrolling π
π 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. π€ (read that again β no guarantees, they said it, not me)
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.
Tagged [inline], [inherited]. Iykyk π
π 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 std::__codecvt_abstract_base< _InternT, _ExternT, _StateT >::do_out().
Tagged [inline], [inherited]. She's the mirror image of in and honestly? slay πͺβ¨
π¦ 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.
Tagged [inline], [inherited]. It's giving "clean up your own mess before you leave the group chat" and honestly we should all take notes π§Ήπ
π Author
Generated automatically by Doxygen for libstdc++ from the source code.
Likeβ¦ nobody wrote this page, a robot did, and the robot ate. π€β¨ Not a single human hand on it and it still looks better than half the docs out there.
one tiny thing before you go, bestie β all that[protected]and[inherited]business is real, so don't go trying to calldo_in,do_out,do_unshift,do_length,do_encoding,do_max_lengthordo_always_noconvstraight off the object. They're hooks. Use the public girls (in,out,unshift). π
and that's the whole page!! footer energy: this one lives in the libstdc++ docs (libststd::codecvt_by...ernT, _StateT >(3cxx)), auto-generated by Doxygen from the source code β so shoutout to the generator, and shoutout to you for reading the entire thing, that's main character behavior fr fr ππ¦π
π¦ 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