std:: btowc
|
헤더 파일에 정의됨
<cwchar>
|
||
|
std::
wint_t
btowc
(
int
c
)
;
|
||
단일 바이트 문자 c 를 해당 와이드 문자로 확장합니다.
대부분의 멀티바이트 문자 인코딩은 ASCII 문자 집합의 문자들을 표현하기 위해 싱글바이트 코드를 사용합니다. 이 함수는 그러한 문자들을 wchar_t 로 변환하는 데 사용될 수 있습니다.
목차 |
매개변수
| c | - | 확장할 단일 바이트 문자 |
반환값
WEOF if 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 << "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
참고 항목
|
가능한 경우 와이드 문자를 싱글바이트 네로우 문자로 축소합니다
(함수) |
|
|
[virtual]
|
문자를
char
에서
CharT
로 변환합니다
(
std::ctype<CharT>
의 가상 protected 멤버 함수)
|
|
C documentation
for
btowc
|
|