std::mbstowcs

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>
std::size_t mbstowcs(wchar_t* dst, constchar* src, std::size_t len)
Converte una stringa di caratteri multibyte dalla matrice il cui primo elemento è puntato da src alla sua rappresentazione dei caratteri di larghezza. Caratteri convertiti sono memorizzati negli elementi successivi puntato da dst. Non più di caratteri len larghi sono scritti nella matrice di destinazione.
Original:
Converts a multibyte character string from the array whose first element is pointed to by src to its wide character representation. Converted characters are stored in the successive elements of the 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.
Ogni carattere viene convertito come per una chiamata a std::mbtowc, tranne che lo stato di conversione mbtowc è inalterato. La conversione si interrompe se:
Original:
Each character is converted as if by a call to std::mbtowc, except that the mbtowc 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.
  • Il carattere null multibyte è stato convertito e memorizzato.
    Original:
    The multibyte 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 valido (nella versione locale corrente C) caratteri multibyte è stato rilevato.
    Original:
    An invalid (in the current C locale) multibyte character was encountered.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • Il carattere successivo grande per essere memorizzato supererebbe len.
    Original:
    The next wide 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.

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::mbsrtowcs 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::mbsrtowcs 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 specifica l'estensione comune: se dst è un puntatore nullo, la funzione restituisce il numero di caratteri estesi che si dovrebbero scrivere a dst, se convertito. Un comportamento simile è standard per std::mbsrtowcs.
Original:
POSIX specifies a common extension: if dst is a null pointer, this function returns the number of wide characters that would be written to dst, if converted. Similar behavior is standard for std::mbsrtowcs.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[modifica]Parametri

dst -
puntatore a vettore di caratteri estesi in cui la stringa larga verrà memorizzato
Original:
pointer to wide character array where the wide string 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 multibyte da convertire
Original:
pointer to the first element of a null-terminated multibyte 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 caratteri larghi disponibili nell'array puntato da 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.

[modifica]Valore di ritorno

In caso di successo, restituisce il numero di caratteri estesi, escluso il L'\0' terminazione, scritti nella matrice di destinazione.
Original:
On success, returns the number of wide characters, excluding the terminating L'\0', 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.
In caso di errore di conversione (se non valido caratteri multibyte è verificato), restituisce -1.
Original:
On conversion error (if invalid multibyte character was encountered), returns -1.
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 <cstdlib>int main(){std::setlocale(LC_ALL, "en_US.utf8");constchar* mbstr = u8"z\u00df\u6c34\U0001d10b";// or u8"zß水𝄋"// or "\x7a\xc3\x9f\xe6\xb0\xb4\xf0\x9d\x84\x8b";wchar_t wstr[5]; std::mbstowcs(wstr, mbstr, 5);std::wcout<<"wide string: "<< wstr <<'\n';}

Output:

wide string: zß水𝄋

[modifica]Vedi anche

converte una stringa di caratteri multibyte stretta alla stringa di larghezza, determinato stato
Original:
converts a narrow multibyte character string to wide 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)[modifica]
converte una stringa larga a stretta stringa di caratteri multibyte
Original:
converts a wide string to narrow multibyte character string
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 externT a internt, come ad esempio durante la lettura dal file
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.

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