ctype::widen
将类型 char 字符在本机字符集的转换区域设置中使用的类型 CharType 对应的字符。
CharType widen(
char byte
) const;
const char *widen(
const char* first,
const char* last,
CharType* dest
) const;
参数
byte
类型字符将转换的本机字符集的。first
对于第一个字符的指针将转换的字符范围内。last
指向字符的指针在将转换的字符范围内的最后一个字符之后。dest
对类型 CharType 第一个字符的指针在存储字符的翻译范围的目标的大小。
返回值
第一个成员函数返回对应于本机类型 char参数字符类型 CharType 的字符。
第二个成员函数返回指向区域设置中使用的类型 CharType 字符的目标范围转换从类型 char本机字符。
备注
第一个成员函数返回 do_widen(byte)。 第二个成员函数返回 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