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] |
(virtual protected std::ctype -)
|
C btowc
| |