Espaços nominais
Variantes
Acções

std::mbsinit

Da cppreference.com
< cpp‎ | string‎ | multibyte

 
 
Biblioteca cordas
Strings terminadas
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.
Cadeias de bytes
Multibyte cordas
Cordas de largura
Classes
Original:
Classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
 
Strings terminadas multibyte
Wide / multibyte conversões
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
Tipos
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
 
Definido no cabeçalho <cwchar>
int mbsinit(conststd::mbstate_t* ps);
Se ps não é um ponteiro nulo, a função mbsinit determina se o objeto pontiagudo para std::mbstate_t descreve o estado de conversão inicial.
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.

Índice

[editar]Notas

Embora um zero inicializado std::mbstate_t sempre representa o estado inicial de conversão, pode haver outros valores de std::mbstate_t que também representam o estado inicial de conversão.
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.

[editar]Parâmetros

ps - pointer to the std::mbstate_t object to examine

[editar]Valor de retorno

0 se ps não é um ponteiro nulo e não reporesent o estado de conversão inicial, valor diferente de zero caso contrário.
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.

[editar]Exemplo

#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";}}

Saída:

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

[editar]Veja também

informação de conversão de estado necessário para repetir seqüências de caracteres 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)[edit]
Documentação C para mbsinit
close