共用方式為


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

需求

標題: <地區設定>

命名空間: std

請參閱

參考

codecvt 類別