Espaces de noms
Variantes
Affichages
Actions

std::mbrtowc

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

 
 
Bibliothèque de chaînes de caractères
Chaînes à zéro 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 chaînes d'octets
Chaines multi-octets
Les chaînes é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
 
Chaînes à zéro 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
 
Defined in header <cwchar>
std::size_t mbrtowc( wchar_t* pwc,

                     const char* s,
                     std::size_t n,

                     std::mbstate_t* ps );
Convertit un caractère multi-octets étroit pour un caractère large .
Original:
Converts a narrow multibyte character to a wide character.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Si s n'est pas un pointeur NULL, inspecte les octets plupart n de la chaîne de caractères multi-octets, en commençant par l'octet pointé par s pour déterminer le nombre d'octets nécessaires pour compléter le caractère multi-octets suivante (y compris les séquences de décalage). Si la fonction détermine que le caractère multi-octets prochaine s est complet et valide, il convertit le caractère large correspondant et le stocke dans *pwc (si pwc n'est pas nulle) .
Original:
If s is not a null pointer, inspects at most n bytes of the multibyte character string, beginning with the byte pointed to by s to determine the number of bytes necessary to complete the next multibyte character (including any shift sequences). If the function determines that the next multibyte character in s is complete and valid, converts it to the corresponding wide character and stores it in *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.
Si s est un pointeur nul, les valeurs de n et pwc sont ignorés et l'appel est équivalent à std::mbrtowc(NULL, "", 1, ps) .
Original:
If s is a null pointer, the values of n and pwc are ignored and call is equivalent to std::mbrtowc(NULL, "", 1, ps).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Si le caractère large produite est le caractère nul, l'état de conversion stockée dans *ps est l'état initial .
Original:
If the wide character produced is the null character, the conversion state stored in *ps is 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.

Sommaire

[modifier] Paramètres

pwc -
pointeur à l'endroit où le caractère large en résultant sera écrit
Original:
pointer to the location where the resulting wide character will be written
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
s -
pointeur vers la chaîne de caractères multi-octets utilisée comme entrée
Original:
pointer to the multibyte character string used as input
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
n -
limiter le nombre d'octets dans s qui peut être examiné
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.
ps -
pointeur à l'état de conversion utilisé pour interpréter la chaîne multi-octets
Original:
pointer to the conversion state used when interpreting the multibyte string
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[modifier] Retourne la valeur

La première des éventualités suivantes qui s'applique:
Original:
The first of the following that applies:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • 0 si le caractère converti à partir s (et stockées dans pwc si non nul) est le caractère nul
    Original:
    0 if the character converted from s (and stored in pwc if non-null) was the null character
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • le nombre d'octets de la [1...n] caractère multi-octets convertis avec succès à partir de s
    Original:
    the number of bytes [1...n] of the multibyte character successfully converted from s
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • static_cast<std::size_t>(-2) si les octets n prochaines constituer une incomplet, mais jusqu'à présent, valide, caractères multi-octets. Rien n'est écrit sur *pwc .
    Original:
    static_cast<std::size_t>(-2) if the next n bytes constitute an incomplete, but so far valid, multibyte character. Nothing is written to *pwc.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • static_cast<std::size_t>(-1) si erreur de codage survient. Rien n'est écrit sur *pwc, le EILSEQ valeur est stockée dans errno et la valeur de *ps n'est pas spécifié .
    Original:
    static_cast<std::size_t>(-1) if encoding error occurs. Nothing is written to *pwc, the value EILSEQ is stored in errno and the value of *ps is left unspecified.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.

[modifier] Exemple

#include <iostream>
#include <clocale>
#include <cstring>
#include <cwchar>
 
void print_mb(const char* ptr)
{
    std::mbstate_t state = std::mbstate_t(); // initial state
    const char* end = ptr + std::strlen(ptr);
    int len;
    wchar_t wc;
    while((len = std::mbrtowc(&wc, ptr, end-ptr, &state)) > 0) {
        std::wcout << "Next " << len << " bytes are the character " << wc << '\n';
        ptr += len;
    }
}
 
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);
}

Résultat :

Next 1 bytes are the character z
Next 2 bytes are the character ß
Next 3 bytes are the character 水
Next 4 bytes are the character 𝄋

[modifier] Voir aussi

convertit le caractère multi-octets suivante de caractères larges
Original:
converts the next multibyte character to wide character
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction) [edit]
convertit le caractère large de sa représentation multi-octets, état donné
Original:
converts a wide character to its multibyte representation, given state
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction) [edit]
[
virtuel
Original:
virtual
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
]
convertit une chaîne de Externt à internt, comme lors de la lecture du fichier
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.

(fonction membre virtuelle protégée de std::codecvt) [edit]
C documentation for mbrtowc