codecvt::encoding

Tests if the encoding of the Byte stream is state dependent, whether the ratio between the Bytes used and the CharTypes produced is constant, and, if so, determines the value of that ratio.

int encoding( ) const throw( );

Return Value

If the return value is positive then that value is the constant number of Byte characters required to produce the CharType character.

The protected virtual member function returns:

  • –1, if the encoding of sequences of type extern_type is state dependent.

  • 0, if the encoding involves sequences of varying lengths.

  • N, if the encoding involves only sequences of length N.

Remarks

The member function returns do_encoding.

Example

// codecvt_encoding.cpp
// compile with: /EHsc
#include <locale>
#include <iostream>
using namespace std;

int main( )   
{
   locale loc ( "German_Germany" );
   int result1 = use_facet<codecvt<char, char, mbstate_t> > ( loc ).encoding ( );
   cout << result1 << endl;
   result1 = use_facet<codecvt<wchar_t, char, mbstate_t> > ( loc ).encoding( );
   cout << result1 << endl;
   result1 = use_facet<codecvt<char, wchar_t, mbstate_t> > ( loc ).encoding( );
   cout << result1 << endl;
}
1
1
1

Requirements

Header: <locale>

Namespace: std

See Also

Reference

codecvt Class