Espacios de nombres
Variantes
Acciones

std::mbsrtowcs

De cppreference.com
< cpp‎ | string‎ | multibyte

 
 
Strings biblioteca
Terminadas en nulo
Original:
Null-terminated strings
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Cadenas de bytes
Multibyte cuerdas
Cadenas anchas
Clases
Original:
Classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_string
char_traits
 
Terminadas en nulo de varios bytes
Ancho / multibyte conversiones
Original:
Wide/multibyte conversions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
mbsinit
mbtowc
mbstowcs
btowc
mbrtowc
mbsrtowcs
mbrtoc16(C++11)
mbrtoc32(C++11)
mblen
Tipos
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
mbstate_t
 
Defined in header <cwchar>
std::size_t mbsrtowcs( wchar_t* dst,

                       const char** src,
                       std::size_t len,

                       std::mbstate_t* ps );
Convierte una secuencia de terminación nula carácter multibyte que comienza en el estado de conversión descrito por *ps, de la matriz cuyo primer elemento es apuntado por *src en la representación de caracteres anchos. Si dst no es nulo, los caracteres convertidos se almacenan en los sucesivos elementos de la matriz wchar_t apuntado por dst. No más de caracteres anchos len se escriben en la matriz de destino .
Original:
Converts a null-terminated multibyte character sequence, which begins in the conversion state described by *ps, from the array whose first element is pointed to by *src to its wide character representation. If dst is not null, converted characters are stored in the successive elements of the wchar_t 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.
Cada carácter multibyte se convierte como si de una llamada a std::mbrtowc. La conversión se para si:
Original:
Each multibyte character is converted as if by a call to std::mbrtowc. 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.
  • El carácter nulo multibyte se convierte y se almacena. src se establece NULL y *ps representa el estado inicial de cambios .
    Original:
    The multibyte null character was converted and stored. src is set to NULL and *ps represents the initial shift state.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • Un carácter multibyte inválida (de acuerdo con la actual configuración regional C) fue encontrado. src se establece en el punto al principio del carácter multibyte sin convertir primero .
    Original:
    An invalid multibyte character (according to the current C locale) was encountered. src is set to point at the beginning of the first unconverted multibyte character.
    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 len exceder. src se establece en el punto al principio del carácter multibyte sin convertir primero. Esta condición no se comprueba si dst==NULL .
    Original:
    the next wide character to be stored would exceed len. src is set to point at the beginning of the first unconverted multibyte character. This condition is not checked if dst==NULL.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.

Contenido

[editar] Parámetros

dst -
puntero al array de caracteres anchos que los resultados serán almacenados
Original:
pointer to wide character array where the results 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 a puntero al primer elemento de una cadena multibyte terminado en nulo
Original:
pointer to pointer to the first element of a null-terminated multibyte string
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.
ps -
puntero al objeto de estado de la conversión
Original:
pointer to the conversion state object
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 caracteres .. Si dst==NULL, devuelve el número de caracteres anchos que se han escrito dado longitud ilimitada .
Original:
On success, returns the number of wide characters, excluding the terminating L'\0', written to the character array.. If dst==NULL, returns the number of wide characters that would have been written given unlimited length.
The text has been machine-translated via Google Translate.
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 static_cast<std::size_t>(-1), tiendas EILSEQ en errno y deja *ps en estado indeterminado .
Original:
On conversion error (if invalid multibyte character was encountered), returns static_cast<std::size_t>(-1), stores EILSEQ in errno, and leaves *ps in unspecified state.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Ejemplo

#include <iostream>
#include <vector>
#include <clocale>
#include <cwchar>
 
void print_as_wide(const char* mbstr)
{
    std::mbstate_t state = std::mbstate_t();
    int len = 1 + std::mbsrtowcs(NULL, &mbstr, 0, &state);
    std::vector<wchar_t> wstr(len);
    std::mbsrtowcs(&wstr[0], &mbstr, wstr.size(), &state);
    std::wcout << "Wide string: " << &wstr[0] << '\n'
               << "The length, including '\\0': " << wstr.size() << '\n';
}
 
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";
    print_as_wide(mbstr);
}

Output:

Wide string: zß水𝄋
The length, including '\0': 5

[editar] Ver también

convierte el carácter multibyte junto al carácter amplio, estado dado
Original:
converts the next multibyte character to wide character, 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) [edit]
convierte una cadena a cadena estrecha gama de caracteres multibyte, estado dado
Original:
converts a wide string to narrow multibyte character 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) [edit]
[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.

(virtuales protegidos of std::codecvt miembro de función) [edit]
C documentation for mbsrtowcs