ctype::widen
ロケールによって使用される型 CharType の対応する文字にネイティブな文字セットの種類 char の文字を変換します。
CharType widen(
char byte
) const;
const char *widen(
const char* first,
const char* last,
CharType* dest
) const;
パラメーター
byte
変換されるネイティブな文字セットの種類の文字の文字。first
変換される文字の範囲の最初の文字へのポインター。last
変換される文字範囲の最後の文字に続く文字へのポインター。dest
変換された文字の範囲を格納する先の範囲の型 CharType の最初の文字へのポインター。
戻り値
一つ目のメンバー関数はネイティブ型 charのパラメーターの文字に対応する型 CharType の文字を返します。
2 番目のメンバー関数は、型 charのネイティブな文字に変換されるロケールによって使用される型 CharType の文字の範囲へのポインターを返します。
解説
一つ目のメンバー関数は do_widenbyte () を返します。2 番目のメンバー関数は do_widen (first、last、dest) を返します。
使用例
// ctype_widen.cpp
// compile with: /EHsc /W3
#include <locale>
#include <iostream>
using namespace std;
int main( )
{
locale loc1 ( "English" );
char *str1 = "Hello everyone!";
wchar_t str2 [16];
bool result1 = (use_facet<ctype<wchar_t> > ( loc1 ).widen
( str1, str1 + strlen(str1), &str2[0] ) != 0); // C4996
str2[strlen(str1)] = '\0';
cout << str1 << endl;
wcout << &str2[0] << endl;
ctype<wchar_t>::char_type charT;
charT = use_facet<ctype<char> > ( loc1 ).widen( 'a' );
}
必要条件
ヘッダー: <locale>
名前空間: std