std::mbsinit
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 <cwchar> | ||
int mbsinit(conststd::mbstate_t* ps); | ||
ps
se non è un puntatore nullo, la funzione mbsinit
determina se l'oggetto appuntito a std::mbstate_t descrive lo stato iniziale di conversione. Original:
If
ps
is not a null pointer, the mbsinit
function determines whether the pointed-to std::mbstate_t object describes the initial conversion 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.
Indice |
[modifica]Note
Sebbene un inizializzati a zero std::mbstate_t sempre rappresenta lo stato iniziale di conversione, vi possono essere altri valori di std::mbstate_t che ne rappresentano anche lo stato iniziale di conversione.
Original:
Although a zero-initialized std::mbstate_t always represents the initial conversion state, there may be other values of std::mbstate_t that also represent the initial conversion 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.
[modifica]Parametri
ps | - | pointer to the std::mbstate_t object to examine |
[modifica]Valore di ritorno
0
ps
se non è un puntatore nullo e non reporesent stato iniziale di conversione, il valore zero altrimenti.Original:
0 if
ps
is not a null pointer and does not reporesent the initial conversion state, nonzero value otherwise.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 <clocale>#include <string>#include <iostream>#include <cwchar> int main(){// allow mbrlen() to work with UTF-8 multibyte encodingstd::setlocale(LC_ALL, "en_US.utf8");// UTF-8 narrow multibyte encodingstd::string str = u8"水";// or u8"\u6c34" or "\xe6\xb0\xb4"std::mbstate_t mb =std::mbstate_t();(void)std::mbrlen(&str[0], 1, &mb);if(!std::mbsinit(&mb)){std::cout<<"After processing the first 1 byte of "<< str <<" the conversion state is not initial\n";} (void)std::mbrlen(&str[1], str.size()-1, &mb);if(std::mbsinit(&mb)){std::cout<<"After processing the remaining 2 bytes of "<< str <<", the conversion state is initial conversion state\n";}}
Output:
After processing the first 1 byte of 水 the conversion state is not initial After processing the remaining 2 bytes of 水, the conversion state is initial conversion state
[modifica]Vedi anche
informazioni sullo stato di conversione necessario per scorrere le stringhe di caratteri multibyte Original: conversion state information necessary to iterate multibyte character strings The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (classe) | |
C documentation for mbsinit |