codecvt::length

确定从外部 Byte的生成特定顺序的多少 Byte的不超过内部 CharType中的许多和返回 Bytes.的该数字。

int length(
    const StateType& _State,
    const Byte* _First1, 
    const Byte* _Last1,
    size_t _Len2
) const;

参数

  • _State
    维护得之间的转换状态调用成员函数。

  • _First1
    对外部序列的开头的指针。

  • _Last1
    对外部序列的结尾的指针。

  • _Len2
    可由成员函数返回的最大字节数。

返回值

表示平移的最大数量计数的整数,而不大于 _Len2,定义由外部源序列位于[_First1,_Last1)。

备注

成员函数返回 do_length(_State,_First1,_Last1,_Len2)。

示例

// codecvt_length.cpp
// compile with: /EHsc
#define _INTL
#include <locale>
#include <iostream>
using namespace std;
#define LEN 90
int main( )   
{
   char* pszExt = "This is the string whose length is to be measured!";
   mbstate_t state = {0};
   locale loc("C");//English_Britain");//German_Germany
   int res = use_facet<codecvt<wchar_t, char, mbstate_t> >
     ( loc ).length( state,
          pszExt, &pszExt[strlen(pszExt)], LEN );
   cout << "The length of the string is: ";
   wcout << res;
   cout << "." << endl;
   exit(-1);
}
  

要求

标头: <locale>

命名空间: std

请参见

参考

codecvt Class