Espaces de noms
Variantes
Affichages
Actions

std::mbsrtowcs

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
mbtowc
mbstowcs
btowc
mbrtowc
mbsrtowcs
mbrtoc16 (C++11)
mbrtoc32 (C++11)
mblen
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 mbsrtowcs( wchar_t* dst,

                       const char** src,
                       std::size_t len,

                       std::mbstate_t* ps );
Convertit une séquence se terminant par null caractères multi-octets, qui commence dans l'état de conversion décrite par *ps, à partir du tableau dont le premier élément est pointé par *src à sa représentation de caractères larges. Si dst n'est pas nulle, les caractères convertis sont stockés dans les éléments successifs de la matrice de wchar_t pointé par dst. Pas plus de caractères len larges sont écrits dans le tableau de destination .
Original:
Converts a null-terminated multibyte character sequence, which begins in the conversion state described by *ps, from the array whose first element is pointed to by *src to its wide character representation. If dst is not null, converted characters are stored in the successive elements of the wchar_t array pointed to by dst. No more than len wide characters are written to the destination array.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Chaque caractère multi-octets est converti comme par un appel à std::mbrtowc. La conversion s'arrête si:
Original:
Each multibyte character is converted as if by a call to std::mbrtowc. The conversion stops if:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • Le caractère multi-octets nuls été converties et stockées. src est réglé sur NULL et *ps représente l'état initial .
    Original:
    The multibyte null character was converted and stored. src is set to NULL and *ps represents 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.
  • Un caractère multi-octets invalide (en fonction du courant locale C) a été rencontrée. src est configuré pour pointer au début de l'caractères multi-octets non convertis premier .
    Original:
    An invalid multibyte character (according to the current C locale) was encountered. src is set to point at the beginning of the first unconverted multibyte character.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • le caractère suivant à stocker serait len dépasser. src est configuré pour pointer au début de l'caractères multi-octets non convertis d'abord. Cette condition n'est pas vérifiée si dst==NULL .
    Original:
    the next wide character to be stored would exceed len. src is set to point at the beginning of the first unconverted multibyte character. This condition is not checked if dst==NULL.
    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

dst -
pointeur sur un tableau de caractères larges où les résultats seront stockés
Original:
pointer to wide character array where the results will be stored
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
src -
pointeur vers un pointeur vers le premier élément d'une chaîne multi-octets à zéro terminal
Original:
pointer to pointer to the first element of a null-terminated multibyte string
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
len -
nombre de caractères larges disponibles dans le tableau pointé par dst
Original:
number of wide characters available in the array pointed to by dst
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ps -
pointeur vers l'objet de l'état de conversion
Original:
pointer to the conversion state object
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

En cas de succès, retourne le nombre de caractères larges, à l'exclusion du L'\0' fin, écrit au tableau de caractères .. Si dst==NULL, retourne le nombre de caractères larges qui auraient été écrites donné une longueur illimitée .
Original:
On success, returns the number of wide characters, excluding the terminating L'\0', written to the character array.. If dst==NULL, returns the number of wide characters that would have been written given unlimited length.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
En cas d'erreur de conversion (si non valide a été rencontré caractères multi-octets), les rendements static_cast<std::size_t>(-1), les magasins EILSEQ dans errno, et laisse dans un état indéterminé *ps .
Original:
On conversion error (if invalid multibyte character was encountered), returns static_cast<std::size_t>(-1), stores EILSEQ in errno, and leaves *ps in unspecified state.
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 <vector>
#include <clocale>
#include <cwchar>
 
void print_as_wide(const char* mbstr)
{
    std::mbstate_t state = std::mbstate_t();
    int len = 1 + std::mbsrtowcs(NULL, &mbstr, 0, &state);
    std::vector<wchar_t> wstr(len);
    std::mbsrtowcs(&wstr[0], &mbstr, wstr.size(), &state);
    std::wcout << "Wide string: " << &wstr[0] << '\n'
               << "The length, including '\\0': " << wstr.size() << '\n';
}
 
int main()
{
    std::setlocale(LC_ALL, "en_US.utf8");
    const char* mbstr = u8"z\u00df\u6c34\U0001d10b"; // or u8"zß水𝄋"
                        // or "\x7a\xc3\x9f\xe6\xb0\xb4\xf0\x9d\x84\x8b";
    print_as_wide(mbstr);
}

Résultat :

Wide string: zß水𝄋
The length, including '\0': 5

[modifier] Voir aussi

convertit le caractère multi-octets suivante caractère large, état donné
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.

(fonction) [edit]
convertit une chaîne large de chaîne de caractères multi-octets étroite, état donné
Original:
converts a wide string to narrow multibyte character string, 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 mbsrtowcs