codecvt::encoding

测试,如果字节流的编码是状态依赖项,在 Bytes和使用的比值生成的 CharType是否是常数,并且,如果是这样,确定该比率的值。

int encoding( ) const throw( );

返回值

如果返回值为正的因此值为 Byte 字符常数数所需的生成 CharType 字符。

受保护的虚成员函数返回:

  • – 1,因此,如果类型 extern_type 序列编码是状态依赖项。

  • 0,因此,如果编码涉及不同长度的序列。

  • N,因此,如果编码仅涉及长度序列 N.

备注

成员函数返回 do_encoding

示例

// 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;
}
  

要求

标头: <locale>

命名空间: std

请参见

参考

codecvt Class