Namespaces
Variants
Views
Actions

std::btowc

From cppreference.com
Defined in header <cwchar>
std::wint_t btowc( int c );

Widens a single-byte character c to its wide character equivalent.

Most multibyte character encodings use single-byte codes to represent the characters from the ASCII character set. This function may be used to convert such characters to wchar_t.

Contents

[edit] Parameters

c - single-byte character to widen

[edit] Return value

WEOF if c is EOF.

Wide character representation of c if (unsigned char)c is a valid single-byte character in the initial shift state, WEOF otherwise.

[edit] Example

#include <cwchar>
#include <cstdio>
#include <clocale>
 
int main()
{
    std::setlocale(LC_ALL, "");
    std::wprintf(L"wide: %lc\nwidened from narrow: %lc\n", L'a', std::btowc('a'));
}

Output:

wide: a
widened from narrow: a

[edit] See also

narrows a wide character to a single-byte narrow character, if possible
(function) [edit]
[virtual]
converts a character or characters from char to charT
(virtual protected member function of std::ctype) [edit]
C documentation for btowc