ctype::widen

转换 char 类型字符。本地字符集中的对区域设置的 CharType 对应类型的字符。

CharType widen(
    char byte
) const;
const char *widen(
    const char* first, 
    const char* last, 
    CharType* dest
) const;

参数

  • byte
    char 类型字符将转换为本机的字符集。

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

要求

页眉: <区域设置>

命名空间: std

请参见

参考

ctype 类