Namespace
Varianti

std::wctomb

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

 
 
Stringhe libreria
Null-stringhe terminate
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.
Byte stringhe
Multibyte stringhe
Stringhe larghe
Classi
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
 
Stringhe multibyte null-terminated
Wide / multibyte conversioni
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
Tipi
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
 
Elemento definito nell'header <cstdlib>
int wctomb( char *s, wchar_t wc );
Converte un wc ampio carattere multibyte di codifica e memorizza (comprese le sequenze di cambio) in array di caratteri il cui primo elemento è puntato da s. Non più di caratteri MB_CUR_MAX vengono memorizzati.
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.
Se wc è il carattere null, il byte null viene scritto s, preceduta da tutte le sequenze di trasferimento necessarie per ripristinare lo stato iniziale del cambio.
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.
Se s è un puntatore nullo, ripristina lo stato di conversione globale e determina se le sequenze di trasferimento vengono usati.
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.

Indice

[modifica] Parametri

s -
puntatore alla matrice di caratteri per l'output
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 -
carattere esteso da convertire
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.

[modifica] Valore di ritorno

Se s non è un puntatore nullo, restituisce il numero di byte che sono contenute nella rappresentazione multibyte di wc o -1 wc se non è un carattere valido.
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.
Se s è un puntatore nullo, consente di ripristinare il suo stato conversione interna per rappresentare lo stato iniziale del cambio e 0 restituisce se la codifica multibyte corrente non è dipendente dallo stato (non utilizza sequenze di trasferimento) o un valore diverso da zero se la codifica multibyte corrente è dipendente dallo stato (utilizza sequenze di trasferimento).
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.

[modifica] Note

Ogni chiamata agli aggiornamenti wctomb lo stato interno di conversione globale (un oggetto statico di std::mbstate_t tipo, noto solo a questa funzione). Se la codifica multibyte utilizza spostamento stati, questa funzione non è rientrante. In ogni caso, più thread non dovrebbe chiamare wctomb senza sincronizzazione: std::wcrtomb può essere utilizzato.
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.

[modifica] Esempio

#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

[modifica] Vedi anche

converte il carattere successivo multibyte a carattere esteso
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.

(funzione) [modifica]
converte un carattere esteso alla sua rappresentazione multibyte, determinato stato
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.

(funzione) [modifica]
[virtuale]
converte una stringa da internt a externT, come ad esempio durante la scrittura su file
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.

(virtuale protetto funzione of std::codecvt membro) [modifica]
C documentation for wctomb