Espacios de nombres
Variantes
Acciones

std::wcstombs

De cppreference.com
< cpp‎ | string‎ | multibyte
 
 
 
Cadenas multibyte terminadas en nulo
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.
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.
 
Definido en el archivo de encabezado <cstdlib>
std::size_t wcstombs( char* dst, const wchar_t* src, std::size_t len)
Convierte una secuencia de caracteres anchos del array cuyo primer elemento es apuntado por src a su representación multibyte estrecho que comienza en el estado inicial de cambios. Caracteres convertidos se almacenan en los elementos sucesivos de la matriz de caracteres apuntada por dst. No más de len bytes se escriben en la matriz de destino .
Original:
Converts a sequence of wide characters from the array whose first element is pointed to by src to its narrow multibyte representation that begins in the initial shift state. Converted characters are stored in the successive elements of the char array pointed to by dst. No more than len bytes 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 se convierte como si por una llamada a std::wctomb, excepto que el estado wctomb de conversión no se ve afectada. La conversión se para si:
Original:
Each character is converted as if by a call to std::wctomb, except that the wctomb's 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.
  • El carácter nulo se convierte y se almacena .
    Original:
    The 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 wchar_t se encontró que no corresponde a un carácter válido en la actual configuración regional C .
    Original:
    A wchar_t was found that does not correspond to a valid character in the current C locale.
    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 multibyte próximo a ser almacenados excedería len .
    Original:
    The next multibyte character to be stored would exceed len.
    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::wcsrtombs 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::wcsrtombs 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.
POSIX especifica una extensión común: si dst es un puntero nulo, esta función devuelve el número de bytes que se van a grabar en dst, si se convierten. Similar comportamiento es estándar para std::wcsrtombs .
Original:
POSIX specifies a common extension: if dst is a null pointer, this function returns the number of bytes that would be written to dst, if converted. Similar behavior is standard for std::wcsrtombs.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Parámetros

dst -
puntero al array de caracteres estrecho donde se realizará el carácter multibyte almacenados
Original:
pointer to narrow character array where the multibyte character 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 terminada en nulo de ancho para convertir
Original:
pointer to the first element of a null-terminated wide 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 bytes disponibles en el array apuntado por dst
Original:
number of byte 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 bytes (incluyendo cualquier secuencia de turnos, pero excluyendo el '\0' terminación) por escrito a la matriz de caracteres cuyo primer elemento es apuntado por dst .
Original:
On success, returns the number of bytes (including any shift sequences, but excluding the terminating '\0') written to the character array whose first element is 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.
En caso de error de conversión (si no válida de caracteres anchos se encontró), devuelve static_cast<std::size_t>(-1) .
Original:
On conversion error (if invalid wide character was encountered), returns static_cast<std::size_t>(-1).
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 <clocale>
#include <cstdlib>
 
int main()
{
    std::setlocale(LC_ALL, "en_US.utf8");
    // UTF-8 narrow multibyte encoding
    const wchar_t* wstr = L"z\u00df\u6c34\U0001d10b"; // or L"zß水𝄋"
    char mbstr[11];
    std::wcstombs(mbstr, wstr, 11);
    std::cout << "multibyte string: " << mbstr << '\n';
}

Salida:

multibyte string: zß水𝄋

[editar] Ver también

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) [editar]
Convierte una cadena de caracteres multibyte estrecha a una cadena ancha.
(función) [editar]
[virtual]
convierte una cadena de internt a externT, tales como cuando se escribe en el archivo
Original:
converts a string from internT to externT, such as when writing to 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) [editar]
Documentación de C para wcstombs