std::mbstowcs
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 <cstdlib>
|
||
std::size_t mbstowcs( wchar_t* dst, const char* src, std::size_t len) |
||
Convierte una cadena de caracteres de varios bytes de la matriz cuyo primer elemento es apuntado por
src
en la representación de caracteres anchos. Caracteres convertidos se almacenan en los elementos sucesivos de la matriz a la que apunta dst
. No más de caracteres anchos len
se escriben en la matriz de destino .Original:
Converts a multibyte character string from the array whose first element is pointed to by
src
to its wide character representation. Converted characters are stored in the successive elements of the array pointed to by dst
. No more than len
wide characters are written to the destination array.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.
Cada carácter se convierte como si por una llamada a std::mbtowc, excepto que el estado de conversión mbtowc no se ve afectada. La conversión se para si:
Original:
Each character is converted as if by a call to std::mbtowc, except that the mbtowc conversion state is unaffected. The conversion stops if:
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.
- El carácter nulo multibyte se convierte y se almacena .Original:The multibyte null character was converted and stored.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Un inválido (en el actual entorno nacional C) carácter multibyte se encontró .Original:An invalid (in the current C locale) multibyte character was encountered.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - El siguiente carácter amplio para ser almacenado sería superior
len
.Original:The next wide character to be stored would exceedlen
.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Contenido |
[editar] Notas
En la mayoría de las implementaciones, esta función actualiza un objeto estático global de std::mbstate_t tipo a medida que procesa a través de la cadena, y no puede ser llamado simultáneamente por dos hilos, std::mbsrtowcs se debe utilizar en tales casos .
Original:
In most implementations, this function updates a global static object of type std::mbstate_t as it processes through the string, and cannot be called simultaneously by two threads, std::mbsrtowcs should be used in such cases.
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.
POSIX especifica una extensión común: si
dst
es un puntero nulo, esta función devuelve el número de caracteres anchos que se habrían de escribir a dst
, si se convierten. Similar comportamiento es estándar para std::mbsrtowcs .Original:
POSIX specifies a common extension: if
dst
is a null pointer, this function returns the number of wide characters that would be written to dst
, if converted. Similar behavior is standard for std::mbsrtowcs.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.
[editar] Parámetros
dst | - | puntero al array de caracteres anchos en la que se almacena la cadena ancha
Original: pointer to wide character array where the wide string will be stored The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
src | - | puntero al primer elemento de una cadena multibyte terminada en nulo para convertir
Original: pointer to the first element of a null-terminated multibyte string to convert The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
len | - | número de caracteres anchos disponibles en el array apuntado por dst
Original: number of wide characters available in the array pointed to by dst The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[editar] Valor de retorno
En caso de éxito, devuelve el número de caracteres anchos, sin incluir el L'\0' termina, se escribe en la matriz de destino .
Original:
On success, returns the number of wide characters, excluding the terminating L'\0', written to the destination array.
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.
En caso de error de conversión (si inválido carácter multibyte fue encontrado), vuelve -1 .
Original:
On conversion error (if invalid multibyte character was encountered), returns -1.
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.
[editar] Ejemplo
Ejecuta este código
#include <iostream> #include <clocale> #include <cstdlib> int main() { std::setlocale(LC_ALL, "en_US.utf8"); const char* mbstr = u8"z\u00df\u6c34\U0001d10b"; // or u8"zß水𝄋" // or "\x7a\xc3\x9f\xe6\xb0\xb4\xf0\x9d\x84\x8b"; wchar_t wstr[5]; std::mbstowcs(wstr, mbstr, 5); std::wcout << "wide string: " << wstr << '\n'; }
Salida:
wide string: zß水𝄋
[editar] Ver también
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) | |
Convierte una cadena ancha a una cadena de caracteres multibyte estrecha. (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 )
|
Documentación de C para mbstowcs
|