std::codecvt_mode
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>| Dclar dans l'en-tte <locale>
|
||
enum codecvt_mode { consume_header = 4, generate_header = 2, little_endian = 1 }; |
||
Les facettes std::codecvt_utf8, std::codecvt_utf16 et std::codecvt_utf8_utf16 accepter une valeur optionnelle de std::codecvt_mode type comme argument de modle, qui spcifie les caractristiques optionnelles de la conversion de la chane unicode .
Original:
The facets std::codecvt_utf8, std::codecvt_utf16, and std::codecvt_utf8_utf16 accept an optional value of type std::codecvt_mode as a template argument, which specifies optional features of the unicode string conversion.
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.
Constantes
Defined in header
<locale> | |
Valeur
Original: Value The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Meaning |
little_endian
|
suppose l'entre est dans l'ordre little-endian (s'applique UTF-16 d'entre uniquement, la valeur par dfaut est big-endian)
Original: assume the input is in little-endian byte order (applies to UTF-16 input only, the default is big-endian) The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
consume_header
|
consommer la marque d'ordre d'octet, si elle est prsente au dbut de la squence d'entre, et (dans le cas de l'UTF-16), s'appuient sur l'ordre des octets qu'il spcifie pour dcoder le reste de l'entre
Original: consume the byte order mark, if present at the start of input sequence, and (in case of UTF-16), rely on the byte order it specifies for decoding the rest of the input The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
generate_header
|
fournir en sortie la marque d'ordre d'octets au dbut de la squence de sortie
Original: output the byte order mark at the start of the output sequence The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Les marques d'ordre d'octet reconnus sont les suivants:
Original:
The recognized byte order marks are:
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.
0xfe 0xff
|
UTF-16 big-endian
Original: UTF-16 big-endian The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
0xff 0xfe
|
UTF-16 little-endian
Original: UTF-16 little-endian The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
0xef 0xbb 0xbf
|
UTF-8 (pas d'effet sur boutisme)
Original: UTF-8 (no effect on endianness) The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Si std::consume_header n'est pas slectionn lors de la lecture d'un fichier commenant par marque d'ordre d'octet, le caractre Unicode U + FEFF (Zero largeur un espace inscable) sera lu comme premier caractre de la chane content .
Original:
If std::consume_header is not selected when reading a file beginning with byte order mark, the Unicode character U+FEFF (Zero width non-breaking space) will be read as the first character of the string content.
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
L'exemple suivant illustre la consommation du BOM UTF-8
Original:
The following example demonstrates consuming the UTF-8 BOM
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.
#include <fstream>
#include <iostream>
#include <string>
#include <locale>
#include <codecvt>
int main()
{
// UTF-8 data with BOM
std::ofstream("text.txt") << u8"\ufeffz\u6c34\U0001d10b";
// read the UTF8 file, skipping the BOM
std::wifstream fin("text.txt");
fin.imbue(std::locale(fin.getloc(),
new std::codecvt_utf8<wchar_t, 0x10ffff, std::consume_header>));
for(wchar_t c; fin.get(c); )
std::cout << std::hex << std::showbase << c << '\n';
}
Rsultat :
0x7a
0x6c34
0x1d10b
Voir aussi
convertis entre les codages de caractres, y compris UTF-8, UTF-16, UTF-32 Original: converts between character encodings, including UTF-8, UTF-16, UTF-32 The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (classe gnrique) | |
(C++11) |
convertit entre UTF-8 et UCS2/UCS4 Original: converts between UTF-8 and UCS2/UCS4 The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (classe gnrique) |
(C++11) |
convertit entre UTF-16 et UCS2/UCS4 Original: converts between UTF-16 and UCS2/UCS4 The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (classe gnrique) |
(C++11) |
converts between UTF-8 and UTF-16 (classe gnrique) |