Namespace
Varianti

std::mbsrtowcs

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
mbtowc
mbstowcs
btowc
mbrtowc
mbsrtowcs
mbrtoc16(C++11)
mbrtoc32(C++11)
mblen
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
 
Defined in 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.
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.
  • Il carattere null multibyte è stato convertito e memorizzato. src è impostato su NULL *ps e rappresenta lo stato iniziale del cambio.
    Original:
    The multibyte null character was converted and stored. src is set to NULL and *ps represents 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. src is 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 len superare. src è impostato per puntare all'inizio del primo carattere multibyte non convertito. Questa condizione non è verificata se dst==NULL.
    Original:
    the next wide character to be stored would exceed len. src is set to point at the beginning of the first unconverted multibyte character. This condition is not checked if dst==NULL.
    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

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.

[modifica] 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.
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.

[modifica] 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

[modifica] 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) [edit]
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) [edit]
[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) [edit]
C documentation for mbsrtowcs