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

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

std::mbsrtowcs

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>
std::size_t mbsrtowcs( wchar_t* dst, const char** src, std::size_t len, std::mbstate_t* ps );
Convertit une squence se terminant par null caractres multi-octets, qui commence dans l'tat de conversion dcrite par *ps, partir du tableau dont le premier lment est point par *src sa reprsentation de caractres larges. Si dst n'est pas nulle, les caractres convertis sont stocks dans les lments successifs de la matrice de wchar_t point par dst. Pas plus de caractres 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 caractre multi-octets est converti comme par un appel std::mbrtowc. La conversion s'arrte 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 caractre multi-octets nuls t converties et stockes. src est rgl sur NULL et *ps reprsente 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 caractre multi-octets invalide (en fonction du courant locale C) a t rencontre. src est configur pour pointer au dbut de l'caractres 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 caractre suivant stocker serait len dpasser. src est configur pour pointer au dbut de l'caractres multi-octets non convertis d'abord. Cette condition n'est pas vrifie 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.

Paramtres

dst -
pointeur sur un tableau de caractres larges o les rsultats seront stocks
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 lment d'une chane multi-octets zro 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 caractres 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.

Retourne la valeur

En cas de succs, retourne le nombre de caractres larges, l'exclusion du L'\0' fin, crit au tableau de caractres .. Si dst==NULL, retourne le nombre de caractres larges qui auraient t crites donn une longueur illimite .
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 caractres multi-octets), les rendements static_cast<std::size_t>(-1), les magasins EILSEQ dans errno, et laisse dans un tat indtermin *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.

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);
}

Rsultat :

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

Voir aussi

convertit le caractre multi-octets suivante caractre 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 chane large de chane de caractres 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 chane 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 protge de std::codecvt) [edit]
C documentation for mbsrtowcs

Web Proxy Viewer  |  New URL  |  Original Page