std::mbsrtowcs
De cppreference.com
[] |
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
<metanoindex/>
<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.
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.
You can help to correct and verify the translation. Click here for instructions.
- Le caractre multi-octets nuls t converties et stockes.
srcest rgl sur NULL et*psreprsente l'tat initial .Original:The multibyte null character was converted and stored.srcis set to NULL and*psrepresents 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.
srcest 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.srcis 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
lendpasser.srcest configur pour pointer au dbut de l'caractres multi-octets non convertis d'abord. Cette condition n'est pas vrifie sidst==NULL.Original:the next wide character to be stored would exceedlen.srcis set to point at the beginning of the first unconverted multibyte character. This condition is not checked ifdst==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.
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.
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) | |
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) | |
[ 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)
|
C documentation for mbsrtowcs
| |