在线文档教程
C++
字符串 | Strings

std::btowc

STD:BTOC

Defined in header
std::wint_t btowc( int c

扩展单字节字符。c与它的宽特性相当。

大多数多字节字符编码使用单字节代码来表示ASCII字符集中的字符。此函数可用于将这些字符转换为wchar_t...

参数

c-single-byte character to widen

返回值

WEOF如果cEOF...

宽字符表示c如果(unsigned char)c是处于初始移位状态的有效单字节字符,WEOF否则。

二次

#include <iostream> #include <cwchar> #include <clocale> void try_widen(char c) { std::wint_t w = std::btowc(c if(w != WEOF) std::cout << "The single-byte character " << +(unsigned char)c << " widens to " << +w << '\n'; else std::cout << "The single-byte character " << +(unsigned char)c << " failed to widen\n"; } int main() { std::setlocale(LC_ALL, "lt_LT.iso88594" std::cout << std::hex << std::showbase << "In Lithuanian ISO-8859-4 locale:\n"; try_widen('A' try_widen('\xdf' // German letter ß (U+00df) in ISO-8859-4 try_widen('\xf9' // Lithuanian letter ų (U+0173) in ISO-8859-4 std::setlocale(LC_ALL, "lt_LT.utf8" std::cout << "In Lithuanian UTF-8 locale:\n"; try_widen('A' try_widen('\xdf' try_widen('\xf9' }

二次

产出:

二次

In Lithuanian ISO-8859-4 locale: The single-byte character 0x41 widens to 0x41 The single-byte character 0xdf widens to 0xdf The single-byte character 0xf9 widens to 0x173 In Lithuanian UTF-8 locale: The single-byte character 0x41 widens to 0x41 The single-byte character 0xdf failed to widen The single-byte character 0xf9 failed to widen

二次

另见

wctobnarrows a wide character to a single-byte narrow character, if possible (function)
do_widen virtualconverts a character or characters from char to charT (virtual protected member function of std::ctype)

c btwc文件

© cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

http://en.cppreference.com/w/cpp/string/multibit/btwc