Share via


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

Reference

ctype Class

Safe Libraries: Standard C++ Library

Other Resources

ctype Members

Change History

Date

History

Reason

March 2009

Corrected.

Customer feedback.