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_type
  • typedef _InternT intern_type
  • typedef codecvt_base::result result
  • typedef _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 call do_in, do_out, do_unshift, do_length, do_encoding, do_max_length or do_always_noconv straight 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