Espacios de nombres
Variantes
Acciones

std::wctomb

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
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 <cstdlib>
int wctomb( char *s, wchar_t wc );
Convierte un wc carácter ancho a multibyte de codificación y almacena (incluyendo cualquier secuencia de turno) en la matriz de caracteres cuyo primer elemento es apuntado por s. No más caracteres MB_CUR_MAX se almacenan .
Original:
Converts a wide character wc to multibyte encoding and stores it (including any shift sequences) in the char array whose first element is pointed to by s. No more than MB_CUR_MAX characters are stored.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Si wc es el carácter nulo, el byte nulo se escribe en s, precedido por las secuencias de desplazamiento necesarias para restablecer el estado inicial de cambios .
Original:
If wc is the null character, the null byte is written to s, preceded by any shift sequences necessary to restore 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.
Si s es un puntero nulo, se restablece el estado de conversión global y determina si las secuencias de desplazamiento se utilizan .
Original:
If s is a null pointer, resets the global conversion state and determines whether shift sequences are used.
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

s -
puntero a la matriz de caracteres para la salida
Original:
pointer to the character array for output
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
wc -
carácter ancho a convertir
Original:
wide character to convert
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

Si s no es un puntero nulo, devuelve el número de bytes que se encuentran en la representación multibyte de wc o -1 wc si no es un carácter válido .
Original:
If s is not a null pointer, returns the number of bytes that are contained in the multibyte representation of wc or -1 if wc is not a valid character.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Si s es un puntero nulo, restablece su estado de conversión interna para representar el estado inicial de cambios y devoluciones si 0 la codificación multibyte actual no es dependiente del estado (no utiliza secuencias de turnos) o un valor distinto de cero si la codificación multibyte actual es dependiente del estado (utiliza secuencias de turnos) .
Original:
If s is a null pointer, resets its internal conversion state to represent the initial shift state and returns 0 if the current multibyte encoding is not state-dependent (does not use shift sequences) or a non-zero value if the current multibyte encoding is state-dependent (uses shift sequences).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Notas

Cada llamada a las actualizaciones de estado interno wctomb la conversión global (un objeto estático de std::mbstate_t tipo, sólo se sabe que esta función). Si la codificación multibyte utiliza los estados turno, esta función no es reentrante. En cualquier caso, varios subprocesos no debe llamar wctomb sin sincronización: std::wcrtomb lugar se puede utilizar .
Original:
Each call to wctomb updates the internal global conversion state (a static object of type std::mbstate_t, only known to this function). If the multibyte encoding uses shift states, this function is not reentrant. In any case, multiple threads should not call wctomb without synchronization: std::wcrtomb may be used instead.
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 <string>
#include <cstdlib>
 
void print_wide(const std::wstring& wstr)
{
    bool shifts = std::wctomb(NULL, 0); // reset the conversion state
    std::cout << "shift sequences " << (shifts ? "are" : "not" ) << " used\n";
    for (wchar_t wc : wstr) {
        std::string mb(MB_CUR_MAX, '\0');
        int ret = std::wctomb(&mb[0], wc);
        std::cout << "multibyte char " << mb << " is " << ret << " bytes\n";
    }
}
 
int main()
{
    std::setlocale(LC_ALL, "en_US.utf8");
    // UTF-8 narrow multibyte encoding
    std::wstring wstr = L"z\u00df\u6c34\U0001d10b"; // or L"zß水𝄋"
    print_wide(wstr);
}

Output:

shift sequences not used
multibyte char z is 1 bytes
multibyte char ß is 2 bytes
multibyte char 水 is 3 bytes
multibyte char 𝄋 is 4 bytes

[editar] Ver también

convierte el carácter multibyte al lado de caracteres anchos
Original:
converts the next multibyte character to wide character
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 carácter ancho a su representación multibyte, estado dado
Original:
converts a wide character to its multibyte representation, 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 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.

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