std::wstring_convert::from_bytes
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 <locale>
|
||
wide_string from_bytes( char byte );
|
(1) | |
wide_string from_bytes( const char* ptr );
|
(2) | |
wide_string from_bytes( const byte_string& str );
|
(3) | |
wide_string from_bytes( const char* first, const char* last);
|
(4) | |
Realiza varios bytes a la conversión de ancho, utilizando la faceta codecvt suministrada en construcción .
Original:
Performs multibyte to wide conversion, using the codecvt facet supplied at construction.
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.
1)
Convierte
byte como si fuera una cadena de longitud 1 a wide_stringOriginal:
Converts
byte as if it was a string of length 1 to wide_stringThe 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)
Convierte la terminación nula carácter multibyte secuencia que comienza en el carácter al que apunta
ptr a wide_stringOriginal:
Converts the null-terminated multibyte character sequence beginning at the character pointed to by
ptr to wide_stringThe 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.
3)
Convierte la cadena
str estrecho para wide_string .Original:
Converts the narrow string
str to wide_string.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.
4)
Convierte el carácter multibyte estrecho
[first, last) secuencia para wide_stringOriginal:
Converts the narrow multibyte character sequence
[first, last) to wide_stringThe 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.
En todos los casos, la conversión comienza en el estado inicial de cambios, a menos que no inicial estado de partida se proporcionó a este constructor
wstring_convert. El número de caracteres convertidos y el valor final del estado de conversión se recuerdan y se puede acceder con state() y converted()Original:
In all cases, the conversion begins in initial shift state, unless non-initial starting state was provided to this
wstring_convert constructor. The number of characters converted and the final value of the conversion state are remembered and can be accessed with state() and converted()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.
Valor de retorno
Un objeto
wide_string con los resultados de varios bytes de conversión gran angular. Si la conversión no y había un suministrado por el usuario a gran error cadena proporcionada al constructor de esta wstring_convert, que devuelve gran error cadena .Original:
A
wide_string object containing the results of multibyte to wide conversion. If the conversion failed and there was a user-supplied wide-error string provided to the constructor of this wstring_convert, returns that wide-error string.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.
Excepciones
Si este objeto
wstring_convert se construyó sin un usuario suministrado por gran error cuerda, tira std::range_error en caso de fallo de conversión .Original:
If this
wstring_convert object was constructed without a user-supplied wide-error string, throws std::range_error on conversion failure.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.
Ejemplo
Ejecuta este código
#include <iostream>
#include <string>
#include <locale>
#include <codecvt>
int main()
{
std::string utf8 = u8"z\u00df\u6c34\U0001d10b"; // or u8"zß水𝄋"
// or "\x7a\xc3\x9f\xe6\xb0\xb4\xf0\x9d\x84\x8b";
// the UTF-8 / UTF-16 standard conversion facet
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> utf16conv;
std::u16string utf16 = utf16conv.from_bytes(utf8.data());
std::cout << "UTF16 conversion produced " << utf16.size() << " code points:\n";
for(char16_t c : utf16)
std::cout << std::hex << std::showbase << c << '\n';
// the UTF-8 / UTF-32 standard conversion facet
std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> utf32conv;
std::u32string utf32 = utf32conv.from_bytes(utf8);
std::cout << "UTF32 conversion produced " << std::dec << utf32.size() << " code points:\n";
for(char32_t c : utf32)
std::cout << std::hex << std::showbase << c << '\n';
}
Salida:
UTF16 conversion produced 5 code points:
0x7a
0xdf
0x6c34
0xd834
0xdd0b
UTF32 conversion produced 4 code points:
0x7a
0xdf
0x6c34
0x1d10b
Ver también
convierte una cadena de ancho en una cadena de bytes Original: converts a wide string into a byte string The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función miembro pública) | |
convierte una cadena de caracteres multibyte estrecho a la cadena de ancho, estado dado Original: converts a narrow multibyte character string to wide string, given state The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función) | |
[virtual] |
convierte una cadena de externT a internt, como cuando al leer el archivo Original: converts a string from externT to internT, such as when reading from file The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (función miembro virtual protegida de std::codecvt)
|