std::wcstombs
Da cppreference.com.
![]() |
Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate.
La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
Elemento definito nell'header <cstdlib>
|
||
std::size_t wcstombs( char* dst, const wchar_t* src, std::size_t len) |
||
Converte una sequenza di caratteri estesi dalla matrice il cui primo elemento è puntato da
src
alla sua rappresentazione multibyte stretta che inizia nello stato di spostamento iniziale. Caratteri convertiti sono memorizzati negli elementi successivi della matrice char puntato da dst
. Non più di byte len
vengono scritti nella matrice di destinazione.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.
You can help to correct and verify the translation. Click here for instructions.
Ogni carattere viene convertito come per una chiamata a std::wctomb, salvo che lo stato di conversione del wctomb non è influenzato. La conversione si interrompe se:
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.
You can help to correct and verify the translation. Click here for instructions.
- Il carattere null è stato convertito e memorizzato.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 è accertato che non corrisponde a un carattere valido nella versione locale corrente 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. - Il carattere multibyte successivo da memorizzare supererebbe
len
.Original:The next multibyte 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.
Indice |
[modifica] Note
Nella maggior parte delle implementazioni, questa funzione aggiorna un oggetto statico globale della std::mbstate_t tipo che elabora attraverso la stringa, e non può essere chiamato contemporaneamente da due fili, std::wcsrtombs deve essere utilizzato in questi casi.
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.
You can help to correct and verify the translation. Click here for instructions.
POSIX specifica l'estensione comune: se
dst
è un puntatore nullo, la funzione restituisce il numero di byte che si dovrebbero scrivere a dst
, se convertito. Un comportamento simile è standard per 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.
You can help to correct and verify the translation. Click here for instructions.
[modifica] Parametri
dst | - | puntatore ad array di caratteri ristretto in cui il carattere multibyte verrà memorizzato
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 | - | puntatore al primo elemento di una stringa con terminazione null larga da convertire
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 | - | numero di byte disponibili nell'array puntato da 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. |
[modifica] Valore di ritorno
In caso di successo, restituisce il numero di byte (comprese le sequenze di cambio, ma escluso il '\0' finale) scritte per l'array di caratteri il cui primo elemento è puntato da
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.
You can help to correct and verify the translation. Click here for instructions.
In caso di errore di conversione (se non valido caratteri larghi veniva rilevato), restituisce 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.
You can help to correct and verify the translation. Click here for instructions.
[modifica] Esempio
#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'; }
Output:
multibyte string: zß水𝄋
[modifica] Vedi anche
converte una stringa larga a stretta stringa a caratteri multibyte, determinato stato 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. (funzione) | |
converte una stringa di caratteri multibyte stretta alla stringa di larghezza Original: converts a narrow multibyte character string to wide string The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (funzione) | |
[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)
|
C documentation for wcstombs
|