[ Web Proxy ]
URL:
Viewing: https://ru.cppreference.com/cpp/string/multibyte/btowc [Back]  [Original]

std::btowc cppreference.com
cppreference.com

std::btowc

cppreference.com
<tbody> </tbody>
std::wint_t btowc( int c );

c .

ASCII. wchar_t.

c

WEOF, c EOF.

c, (unsigned char)c , WEOF .

#include <clocale>
#include <cwchar>
#include <iostream>

void try_widen(char c)
{
    std::wint_t w = std::btowc(c);
    if (w != WEOF)
        std::cout << "  " << +(unsigned char)c
                  << "   " << +w << '\n';
    else
        std::cout << "  " << +(unsigned char)c
                  << "   \n";
}

int main()
{
    std::setlocale(LC_ALL, "lt_LT.iso88594");
    std::cout << std::hex << std::showbase << "   ISO-8859-4:\n";
    try_widen('A');
    try_widen('\xdf'); //    (U+00df)  ISO-8859-4
    try_widen('\xf9'); //    (U+0173)  ISO-8859-4

    std::setlocale(LC_ALL, "lt_LT.utf8");
    std::cout << "   UTF-8:\n";
    try_widen('A');
    try_widen('\xdf');
    try_widen('\xf9');
}

:

   ISO-8859-4:
  0x41   0x41
  0xdf   0xdf
  0xf9   0x173
   UTF-8:
  0x41   0x41
  0xdf   
  0xf9   

,
() []
[virtual]
char charT
:
converts a character or characters from char to charT
Google.
. .

(virtual protected std::ctype -) []
C btowc

Web Proxy Viewer  |  New URL  |  Original Page