codecvt::length
确定从外部 Byte。生成特定序列的多少 Byte内。不超过内部 CharType的许多和返回 Byte的 . 的该数字。
int length(
const StateType& _State,
const Byte* _First1,
const Byte* _Last1,
size_t _Len2
) const;
参数
_State
保持在指向成员函数调用之间的状态转换。_First1
对外部序列的开头的指针。_Last1
对外部序列的结尾的指针。_Len2
可供成员函数返回的最大字节数。
返回值
表示变换的最大计数的整数,而不大于 _Len2,定义由外部源序列。[_First1,_Last1)。
备注
成员函数返回*_State,_First1*,do_length( _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);
}
要求
页眉: <区域设置>
命名空间: std