libstdc++: std::codecvt< char16_t, char, mbstate_t > Class Reference

libstdc++

std::codecvt< char16_t, char, mbstate_t > Class Reference

`#include <codecvt.h>`

Inheritance diagram for std::codecvt< char16_t, char, mbstate_t >:
[legend]

## Public Types
typedef char | extern_type
typedef char16_t | intern_type
typedef codecvt_base::result | result
typedef mbstate_t | state_type

## Public Member Functions
| codecvt (size_t __refs=0)
bool | always_noconv () const throw ()
bool | always_noconv () const throw ()
int | encoding () const throw ()
int | encoding () const throw ()
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
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 (state_type &__state, const extern_type *__from, const extern_type *__end, size_t __max) const
int | length (state_type &__state, const extern_type *__from, const extern_type *__end, size_t __max) const
int | max_length () const throw ()
int | max_length () const throw ()
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 | 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 (state_type &__state, extern_type *__to, extern_type *__to_end, extern_type *&__to_next) const
result | unshift (state_type &__state, extern_type *__to, extern_type *__to_end, extern_type *&__to_next) const

## Static Public Attributes
static locale::id | id

## 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) const
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 (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 (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 __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_create_c_locale (__c_locale &__cloc, const char *__s, __c_locale __old=0)
static void | _S_destroy_c_locale (__c_locale &__cloc)
static void | _S_destroy_c_locale (__c_locale &__cloc)
static __c_locale | _S_get_c_locale ()
static __c_locale | _S_get_c_locale ()
static const char * | _S_get_c_name () throw ()
static const char * | _S_get_c_name () throw ()
static __c_locale | _S_lc_ctype_c_locale (__c_locale __cloc, const char *__s)
static __c_locale | _S_lc_ctype_c_locale (__c_locale __cloc, const char *__s)

## Protected Attributes
__c_locale | _M_c_locale_codecvt

## Detailed Description

Class codecvt<char16_t, char, mbstate_t> specialization.

Converts between UTF-16 and UTF-8.

Definition at line 475 of file codecvt.h.

## Member Typedef Documentation

## ◆ extern_type

typedef char std::codecvt< char16_t, char, mbstate_t >::extern_type

Definition at line 481 of file codecvt.h.

## ◆ intern_type

typedef char16_t std::codecvt< char16_t, char, mbstate_t >::intern_type

Definition at line 480 of file codecvt.h.

## ◆ result

typedef codecvt_base::result std::codecvt< char16_t, char, mbstate_t >::result

Definition at line 287 of file codecvt.h.

## ◆ state_type

typedef mbstate_t std::codecvt< char16_t, char, mbstate_t >::state_type

Definition at line 482 of file codecvt.h.

## Constructor & Destructor Documentation

## ◆ codecvt()

std::codecvt< char16_t, char, mbstate_t >::codecvt | ( | size_t | __refs = 0 | ) |
| inlineexplicit

Definition at line 488 of file codecvt.h.

## Member Function Documentation

## ◆ always_noconv() [1/2]

bool std::__codecvt_abstract_base< char16_t, char, mbstate_t >::always_noconv | ( |  | ) | const
throw | ( | ) |  |  |
| inlineinherited

Definition at line 218 of file codecvt.h.

## ◆ always_noconv() [2/2]

bool std::__codecvt_abstract_base< char16_t, char, mbstate_t >::always_noconv | ( |  | ) | const
throw | ( | ) |  |  |
| inline

Definition at line 218 of file codecvt.h.

## ◆ do_always_noconv()

virtual bool std::codecvt< char16_t, char, mbstate_t >::do_always_noconv | ( |  | ) | const
throw | ( | ) |  |  |
| protectedvirtual

Implements std::__codecvt_abstract_base< char16_t, char, mbstate_t >.

## ◆ do_encoding()

virtual int std::codecvt< char16_t, char, mbstate_t >::do_encoding | ( |  | ) | const
throw | ( | ) |  |  |
| protectedvirtual

Implements std::__codecvt_abstract_base< char16_t, char, mbstate_t >.

## ◆ do_in()

virtual result std::codecvt< char16_t, char, mbstate_t >::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
| protectedvirtual

Implements std::__codecvt_abstract_base< char16_t, char, mbstate_t >.

## ◆ do_length()

virtual int std::codecvt< char16_t, char, mbstate_t >::do_length | ( | state_type & | ,
|  | const extern_type * | __from,
|  | const extern_type * | __end,
|  | size_t | __max ) const
| protectedvirtual

Implements std::__codecvt_abstract_base< char16_t, char, mbstate_t >.

## ◆ do_max_length()

virtual int std::codecvt< char16_t, char, mbstate_t >::do_max_length | ( |  | ) | const
throw | ( | ) |  |  |
| protectedvirtual

Implements std::__codecvt_abstract_base< char16_t, char, mbstate_t >.

## ◆ do_out()

virtual result std::codecvt< char16_t, char, mbstate_t >::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
| protectedvirtual

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< char16_t, char, mbstate_t >.

## ◆ do_unshift()

virtual result std::codecvt< char16_t, char, mbstate_t >::do_unshift | ( | state_type & | __state,
|  | extern_type * | __to,
|  | extern_type * | __to_end,
|  | extern_type *& | __to_next ) const
| protectedvirtual

Implements std::__codecvt_abstract_base< char16_t, char, mbstate_t >.

## ◆ encoding() [1/2]

int std::__codecvt_abstract_base< char16_t, char, mbstate_t >::encoding | ( |  | ) | const
throw | ( | ) |  |  |
| inlineinherited

Definition at line 214 of file codecvt.h.

## ◆ encoding() [2/2]

int std::__codecvt_abstract_base< char16_t, char, mbstate_t >::encoding | ( |  | ) | const
throw | ( | ) |  |  |
| inline

Definition at line 214 of file codecvt.h.

## ◆ in() [1/2]

result std::__codecvt_abstract_base< char16_t, char, mbstate_t >::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
| inlineinherited

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.

Definition at line 204 of file codecvt.h.

## ◆ in() [2/2]

result std::__codecvt_abstract_base< char16_t, char, mbstate_t >::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

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.

Definition at line 204 of file codecvt.h.

## ◆ length() [1/2]

int std::__codecvt_abstract_base< char16_t, char, mbstate_t >::length | ( | state_type & | __state,
|  | const extern_type * | __from,
|  | const extern_type * | __end,
|  | size_t | __max ) const
| inlineinherited

Definition at line 222 of file codecvt.h.

## ◆ length() [2/2]

int std::__codecvt_abstract_base< char16_t, char, mbstate_t >::length | ( | state_type & | __state,
|  | const extern_type * | __from,
|  | const extern_type * | __end,
|  | size_t | __max ) const
| inline

Definition at line 222 of file codecvt.h.

## ◆ max_length() [1/2]

int std::__codecvt_abstract_base< char16_t, char, mbstate_t >::max_length | ( |  | ) | const
throw | ( | ) |  |  |
| inlineinherited

Definition at line 227 of file codecvt.h.

## ◆ max_length() [2/2]

int std::__codecvt_abstract_base< char16_t, char, mbstate_t >::max_length | ( |  | ) | const
throw | ( | ) |  |  |
| inline

Definition at line 227 of file codecvt.h.

## ◆ out() [1/2]

result std::__codecvt_abstract_base< char16_t, char, mbstate_t >::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
| inlineinherited

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.

Definition at line 124 of file codecvt.h.

## ◆ out() [2/2]

result std::__codecvt_abstract_base< char16_t, char, mbstate_t >::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

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.

Definition at line 124 of file codecvt.h.

## ◆ unshift() [1/2]

result std::__codecvt_abstract_base< char16_t, char, mbstate_t >::unshift | ( | state_type & | __state,
|  | extern_type * | __to,
|  | extern_type * | __to_end,
|  | extern_type *& | __to_next ) const
| inlineinherited

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.

Definition at line 163 of file codecvt.h.

## ◆ unshift() [2/2]

result std::__codecvt_abstract_base< char16_t, char, mbstate_t >::unshift | ( | state_type & | __state,
|  | extern_type * | __to,
|  | extern_type * | __to_end,
|  | extern_type *& | __to_next ) const
| inline

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.

Definition at line 163 of file codecvt.h.

## Member Data Documentation

## ◆ _M_c_locale_codecvt

__c_locale std::codecvt< char16_t, char, mbstate_t >::_M_c_locale_codecvt
| protected

Definition at line 293 of file codecvt.h.

## ◆ id

locale::id std::codecvt< char16_t, char, mbstate_t >::id
| static

Definition at line 485 of file codecvt.h.

The documentation for this class was generated from the following file:

- codecvt.h