std::mbtowc
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>
|
||
int mbtowc( wchar_t* pwc, const char* s, std::size_t n ) |
||
Converte un carattere multibyte il cui primo byte è puntato da
s
a un carattere ampio, scritto *pwc
pwc
se non è nullo.Original:
Converts a multibyte character whose first byte is pointed to by
s
to a wide character, written to *pwc
if pwc
is not null.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.
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.
You can help to correct and verify the translation. Click here for instructions.
Indice |
[modifica] Parametri
s | - | puntatore al carattere multibyte
Original: pointer to the multibyte character The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
n | - | limitare il numero di byte in s che può essere esaminato
Original: limit on the number of bytes in s that can be examined The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
pwc | - | puntatore al carattere esteso per l'output
Original: pointer to the wide character for output 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 nel carattere multibyte o -1 se i primi byte puntato da s
non costituiscono un carattere valido multibyte o 0 s
se è puntato verso il nulla charcter '\0'.Original:
If
s
is not a null pointer, returns the number of bytes that are contained in the multibyte character or -1 if the first bytes pointed to by s
do not form a valid multibyte character or 0 if s
is pointing at the null charcter '\0'.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.
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.
You can help to correct and verify the translation. Click here for instructions.
[modifica] Note
Ogni chiamata agli aggiornamenti
mbtowc
lo stato interno di conversione globale (un oggetto statico di std::mbstate_t tipo, noto solo a questa funzione). Se la codifica multibyte utilizza gli stati di spostamento, è necessario prestare attenzione al fine di evitare scansioni backtracking o multipli. In ogni caso, più thread non dovrebbe chiamare mbtowc
senza sincronizzazione: std::mbrtowc può essere utilizzato.Original:
Each call to
mbtowc
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, care must be taken to avoid backtracking or multiple scans. In any case, multiple threads should not call mbtowc
without synchronization: std::mbrtowc 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.
You can help to correct and verify the translation. Click here for instructions.
[modifica] Esempio
#include <iostream> #include <clocale> #include <cstring> #include <cstdlib> int print_mb(const char* ptr) { std::mbtowc(NULL, 0, 0); // reset the conversion state const char* end = ptr + std::strlen(ptr); int ret; for (wchar_t wc; (ret = std::mbtowc(&wc, ptr, end-ptr)) > 0; ptr+=ret) { std::wcout << wc; } std::wcout << '\n'; return ret; } int main() { std::setlocale(LC_ALL, "en_US.utf8"); // UTF-8 narrow multibyte encoding const char* str = u8"z\u00df\u6c34\U0001d10b"; // or u8"zß水𝄋" // or "\x7a\xc3\x9f\xe6\xb0\xb4\xf0\x9d\x84\x8b"; print_mb(str); }
Output:
zß水𝄋
[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) | |
restituisce il numero di byte nel carattere multibyte successivo Original: returns the number of bytes in the next multibyte character 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 mbtowc
|