std::mbsrtowcs
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. |
<metanoindex/>
<tbody> </tbody>| Elemento definito nell'header <cwchar>
|
||
std::size_t mbsrtowcs( wchar_t* dst, const char** src, std::size_t len, std::mbstate_t* ps ); |
||
Converte con terminazione null sequenza di caratteri multibyte, che inizia nello stato di conversione descritta da
*ps, dalla matrice il cui primo elemento è puntato da *src alla sua rappresentazione dei caratteri di larghezza. dst se non è nullo, caratteri convertiti vengono memorizzati negli elementi successivi della matrice wchar_t puntato da dst. Non più di caratteri len larghi sono scritti nella matrice di destinazione.Original:
Converts a null-terminated multibyte character sequence, which begins in the conversion state described by
*ps, from the array whose first element is pointed to by *src to its wide character representation. If dst is not null, converted characters are stored in the successive elements of the wchar_t 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.
You can help to correct and verify the translation. Click here for instructions.
Ogni carattere multibyte viene convertito come per una chiamata a std::mbrtowc. La conversione si interrompe se:
Original:
Each multibyte character is converted as if by a call to std::mbrtowc. 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 multibyte è stato convertito e memorizzato.
srcè impostato su NULL*pse rappresenta lo stato iniziale del cambio.Original:The multibyte null character was converted and stored.srcis set to NULL and*psrepresents 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. - Un carattere multibyte valido (in base alla corrente C locale) è stato rilevato.
srcè impostato per puntare all'inizio del primo carattere multibyte non convertito.Original:An invalid multibyte character (according to the current C locale) was encountered.srcis set to point at the beginning of the first unconverted multibyte character.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 sarebbe
lensuperare.srcè impostato per puntare all'inizio del primo carattere multibyte non convertito. Questa condizione non è verificata sedst==NULL.Original:the next wide character to be stored would exceedlen.srcis set to point at the beginning of the first unconverted multibyte character. This condition is not checked ifdst==NULL.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Parametri
| dst | - | puntatore a vettore di caratteri estesi in cui i risultati vengono memorizzati
Original: pointer to wide character array where the results 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 puntatore al primo elemento di una stringa con terminazione null multibyte
Original: pointer to pointer to the first element of a null-terminated multibyte string 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. |
| ps | - | puntatore all'oggetto stato di conversione
Original: pointer to the conversion state object The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Valore di ritorno
In caso di successo, restituisce il numero di caratteri estesi, escluso il
L'\0' terminazione, scritto per l'array di caratteri.. Se dst==NULL, restituisce il numero di caratteri estesi che sarebbero state scritte in lunghezza illimitata.Original:
On success, returns the number of wide characters, excluding the terminating
L'\0', written to the character array.. If dst==NULL, returns the number of wide characters that would have been written given unlimited length.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 multibyte è verificato), ritorna
static_cast<std::size_t>(-1), negozi EILSEQ in errno e lascia *ps in stato specificato.Original:
On conversion error (if invalid multibyte character was encountered), returns
static_cast<std::size_t>(-1), stores EILSEQ in errno, and leaves *ps in unspecified state.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.
Esempio
#include <iostream>
#include <vector>
#include <clocale>
#include <cwchar>
void print_as_wide(const char* mbstr)
{
std::mbstate_t state = std::mbstate_t();
int len = 1 + std::mbsrtowcs(NULL, &mbstr, 0, &state);
std::vector<wchar_t> wstr(len);
std::mbsrtowcs(&wstr[0], &mbstr, wstr.size(), &state);
std::wcout << "Wide string: " << &wstr[0] << '\n'
<< "The length, including '\\0': " << wstr.size() << '\n';
}
int main()
{
std::setlocale(LC_ALL, "en_US.utf8");
const char* mbstr = u8"z\u00df\u6c34\U0001d10b"; // or u8"zß水𝄋"
// or "\x7a\xc3\x9f\xe6\xb0\xb4\xf0\x9d\x84\x8b";
print_as_wide(mbstr);
}
Output:
Wide string: zß水𝄋
The length, including '\0': 5
Vedi anche
converte il carattere successivo multibyte a carattere esteso, determinato stato Original: converts the next multibyte character to wide character, 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 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) | |
[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)
|
C documentation for mbsrtowcs
| |