std::wbuffer_convert<Codecvt,Elem,Tr>:: rdbuf
From cppreference.net
<
cpp
|
locale
|
wbuffer convert
C++
Text processing library
| Localization library | |||||||||||||||||||||||||
| Regular expressions library (C++11) | |||||||||||||||||||||||||
| Formatting library (C++20) | |||||||||||||||||||||||||
| Null-terminated sequence utilities | |||||||||||||||||||||||||
| Byte strings | |||||||||||||||||||||||||
| Multibyte strings | |||||||||||||||||||||||||
| Wide strings | |||||||||||||||||||||||||
| Primitive numeric conversions | |||||||||||||||||||||||||
|
|||||||||||||||||||||||||
| Text encoding identifications | |||||||||||||||||||||||||
|
|||||||||||||||||||||||||
Localization library
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::wbuffer_convert
| Member functions | ||||
|
wbuffer_convert::rdbuf
|
||||
|
std::
streambuf
*
rdbuf
(
)
const
;
|
(1) | |
|
std::
streambuf
*
rdbuf
(
std::
streambuf
*
bytebuf
)
;
|
(2) | |
1)
基になるバイトストリームへのポインタを返します。
2)
関連付けられたバイトストリームを
bytebuf
で置き換えます。
戻り値
1)
bufptr
2)
bufptr
の前の値
例
このコードを実行
#include <codecvt> #include <iostream> #include <locale> #include <sstream> int main() { // UTF-8 から UCS4 への変換 std::stringbuf utf8buf("z\u00df\u6c34\U0001d10b"); // または "\x7a\xc3\x9f\xe6\xb0\xb4\xf0\x9d\x84\x8b" // または u8"zß水𝄋" std::wbuffer_convert<std::codecvt_utf8<wchar_t>> conv(&utf8buf); std::wistream ucsbuf(&conv); std::cout << "Reading from a UTF-8 stringbuf via wbuffer_convert: " << std::hex << std::showbase; for (wchar_t c; ucsbuf.get(c);) std::cout << static_cast<std::wint_t>(c) << ' '; // 同じ wbuffer_convert を再利用して UCS4 から UTF-8 への出力を処理 conv.rdbuf(std::cout.rdbuf()); std::wostream out(&conv); std::cout << "\nSending UCS4 data to std::cout via wbuffer_convert: "; out << L"z\u00df\u6c34\U0001d10b\n"; }
出力:
Reading from a UTF-8 stringbuf via wbuffer_convert: 0x7a 0xdf 0x6c34 0x1d10b Sending UCS4 data to std::cout via wbuffer_convert: zß水𝄋
関連項目
wbuffer_convert
を新しく構築する
(public member function) |