다음을 통해 공유


ctype::_Widen_s

Converts a character of type char in the native character set to the corresponding character of type CharType used by a locale.

const char *_Widen_s(
    const char *_First,
    const char *_Last,
    CharType *_Dest,
    size_t _Dest_size
) const;

Parameters

  • _First
    A pointer to the first character in the range of characters to be converted.

  • _Last
    A pointer to the character immediately following the last character in the range of characters to be converted.

  • _Dest
    A pointer to the first character of type CharType in the destination range that stores the converted range of characters.

  • _Dest_size
    The size of _Dest. If CharType is char, then this is in bytes. If CharType is wchar_t, then this is in words.

Return Value

This member function returns a pointer to the destination range of characters of type CharType used by a locale converted from native characters of type char.

Remarks

This member function returns _Do_widen_s(_First, _Last, _Dest, _DestSize).

Example

// ctype__Widen_s.cpp
// compile with: /EHsc
#include <locale>
#include <iostream>
using namespace std;

int main( )
{
    locale loc1("English");
    char *str1 = "Hello everyone!";
    const int str2_size = 16;
    wchar_t str2[str2_size];
    bool result1 = (use_facet<ctype<wchar_t> >(loc1)._Widen_s
        (str1, str1 + strlen(str1), &str2[0], str2_size) != 0);
    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');
}

Hello everyone!
Hello everyone!

Requirements

Header: <locale>

Namespace: std

See Also

Concepts

ctype Class

ctype Members

Safe Libraries: Standard C++ Library