std::wbuffer_convert::rdbuf
De cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
<metanoindex/>
<tbody> </tbody>| Déclaré dans l'en-tête <locale>
|
||
std::streambuf* rdbuf() const; |
(1) | |
std::streambuf* rdbuf( std::streambuf* bytebuf ); |
(2) | |
1)
renvoie le pointeur vers le flux d'octets sous-jacent
Original:
returns the pointer to the underlying byte stream
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
2)
remplace le flux d'octets associé avec
bytebufOriginal:
replaces the associated byte stream with
bytebufThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
.
Retourne la valeur
1)
le flux d'octets sous-jacente
Original:
the current underlying byte stream
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
2)
le flux d'octets précédente
Original:
the previous byte stream
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Exemple
#include <iostream>
#include <sstream>
#include <locale>
#include <codecvt>
int main()
{
// convert UTF-8 to UCS4
std::stringbuf utf8buf(u8"z\u00df\u6c34\U0001d10b"); // or u8"zß水𝄋"
// or "\x7a\xc3\x9f\xe6\xb0\xb4\xf0\x9d\x84\x8b";
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:\n";
for(wchar_t c; ucsbuf.get(c); )
std::cout << std::hex << std::showbase << c << '\n';
// reuse the same wbuffer_convert to handle UCS4 to UTF-8 output
conv.rdbuf(std::cout.rdbuf());
std::wostream out(&conv);
std::cout << "Sending UCS4 data to std::cout via wbuffer_convert:\n";
out << L"z\u00df\u6c34\U0001d10b\n";
}
Résultat :
Reading from a UTF-8 stringbuf via wbuffer_convert:
0x7a
0xdf
0x6c34
0x1d10b
Sending UCS4 data to std::cout via wbuffer_convert:
zß水𝄋
Voir aussi
construit un nouveau wbuffer_convert Original: constructs a new wbuffer_convert The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction membre publique) | |