[ Web Proxy ]
URL:
Viewing: https://fr.cppreference.com/cpp/string/multibyte/mbsinit [Back]  [Original]

std::mbsinit cppreference.com
cppreference.com
Espaces de noms
Variantes

std::mbsinit

De cppreference.com

<metanoindex/>

 
 
Bibliothque de chanes de caractres
Chanes zro terminal
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.
Les chanes d'octets
Chaines multi-octets
Les chanes tendues
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.
basic_string
char_traits
 
Chanes zro terminal multi-octets
Large / multi-octets conversions
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
Types
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
 
<tbody> </tbody>
Dclar dans l'en-tte <cwchar>
int mbsinit( const std::mbstate_t* ps);
Si ps n'est pas un pointeur NULL, la fonction mbsinit dtermine si l'objet point std::mbstate_t dcrit l'tat de conversion initial .
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.

Notes

Bien qu'un initialis zro std::mbstate_t reprsente toujours l'tat de conversion initial, il peut y avoir d'autres valeurs de std::mbstate_t qui reprsentent galement l'tat de conversion initial .
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.

Paramtres

ps -
pointeur vers l'objet std :: mbstate_t examiner
Original:
pointer to the std::mbstate_t object to examine
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Retourne la valeur

0 si ps n'est pas un pointeur NULL et ne reporesent l'tat initial de conversion, valeur diffrente de zro autrement .
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.

Exemple

#include <clocale>
#include <string>
#include <iostream>
#include <cwchar>

int main()
{
    // allow mbrlen() to work with UTF-8 multibyte encoding
    std::setlocale(LC_ALL, "en_US.utf8");
    // UTF-8 narrow multibyte encoding
    std::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";
    }
}

Rsultat :

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

Voir aussi

informations sur l'tat de conversion ncessaire pour parcourir les chanes de caractres multi-octets
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]
C documentation for mbsinit

Web Proxy Viewer  |  New URL  |  Original Page