std::codecvt_mode - cppreference.com
De cppreference.com
|
|
Esta página se ha traducido por ordenador/computador/computadora de la versión en inglés de la Wiki usando Google Translate. La traducción puede contener errores y palabras aparatosas/incorrectas. Planea sobre el texto para ver la versión original. Puedes ayudar a corregir los errores y mejorar la traducción. Para instrucciones haz clic aquí. |
| Definido en el archivo de encabezado |
||
|
|
||
Las facetas std::codecvt_utf8, std::codecvt_utf16, y std::codecvt_utf8_utf16 aceptar un valor opcional de std::codecvt_mode tipo como un argumento de plantilla, que especifica las características opcionales de la conversión cadena 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.
Constantes
Definido en el archivo de encabezado | |
Valor Original: Value The text has been machine-translated via Google Translate. |
Meaning |
little_endian
|
asumir la entrada está en el orden de bytes little-endian (se aplica a UTF-16 sólo entrada, el valor predeterminado es 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. |
consume_header
|
consumir la marca de orden de bytes, si está presente al comienzo de la secuencia de entrada, y (en caso de UTF-16), se basan en el orden de bytes que especifica para la descodificación del resto de la entrada 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. |
generate_header
|
la salida de la marca de orden de bytes en el inicio de la secuencia de salida Original: output the byte order mark at the start of the output sequence The text has been machine-translated via Google Translate. |
Las marcas byte de orden reconocidas son:
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.
0xfe 0xff
|
UTF-16 big-endian Original: UTF-16 big-endian The text has been machine-translated via Google Translate. |
0xff 0xfe
|
UTF-16 little-endian Original: UTF-16 little-endian The text has been machine-translated via Google Translate. |
0xef 0xbb 0xbf
|
UTF-8 (ningún efecto sobre endian) Original: UTF-8 (no effect on endianness) The text has been machine-translated via Google Translate. |
Si no se selecciona std::consume_header al leer un archivo que comience con la marca de orden de bytes, el carácter Unicode U + FEFF (Zero ancho espacio de no separación) se lee como el primer carácter de la cadena de contenido .
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.
Ejemplo
El ejemplo siguiente muestra el consumo de UTF-8 lista de materiales
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.
#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'; }
Salida:
Ver también
| Convierte entre codificaciones de caracteres, incluyendo UTF-8, UTF-16, UTF-32. (plantilla de clase) [editar] | |
(C++11)(en desuso en C++17) |
Convierte entre UTF-8 y UCS2/UCS4. (plantilla de clase) [editar] |
(C++11)(en desuso en C++17) |
Convierte entre UTF-16 y UCS2/UCS4. (plantilla de clase) [editar] |
(C++11)(en desuso en C++17) |
Convierte entre UTF-8 y UTF-16. (plantilla de clase) [editar] |