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)。
解説
このメンバー関数は 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