std::wcsrtombs — cppreference.com
De cppreference.com
<metanoindex/>
<tbody> </tbody>
| Déclaré dans l'en-tête <cwchar> |
||
|
|
||
Convertit une séquence de caractères larges du tableau dont le premier élément est pointé par *src à sa représentation multi-octets étroite qui commence dans l'état de conversion décrite par *ps. Si dst n'est pas nulle, les caractères convertis sont stockés dans les éléments successifs du tableau de caractères pointée par dst. Pas plus que len octets sont écrits dans le tableau de destination .
Original:
Converts a sequence of wide characters from the array whose first element is pointed to by *src to its narrow multibyte representation that begins in the conversion state described by *ps. If dst is not null, converted characters are stored in the successive elements of the char array pointed to by dst. No more than len bytes 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 personnage est transformé comme par un appel à std::wcrtomb. La conversion s'arrête si:
Original:
Each character is converted as if by a call to std::wcrtomb. 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 nul a été transformé et stocké.
srcest réglé sur NULL et*psreprésente l'état initial .Original:
The 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
wchar_ta été trouvé qui ne correspond pas à un caractère valide dans la locale courante C.srcest configuré pour pointer sur le premier caractère large non converti .Original:
A
wchar_twas found that does not correspond to a valid character in the current C locale.srcis set to point at the first unconverted wide 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 multi-octets suivant à mémoriser serait
lendépasser.srcest configuré pour pointer sur le premier caractère large non converti. Cette condition n'est pas vérifiée sidst==NULL.Original:
the next multibyte character to be stored would exceed
len.srcis set to point at the first unconverted wide 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.
Paramètres
| dst | - | pointeur sur un tableau de caractère étroit où les caractères multi-octets sera stockée Original: pointer to narrow character array where the multibyte characters will be stored The text has been machine-translated via Google Translate. |
| src | - | pointeur vers un pointeur vers le premier élément d'une chaîne se terminant largeur Original: pointer to pointer to the first element of a null-terminated wide string The text has been machine-translated via Google Translate. |
| len | - | nombre d'octets disponibles dans le tableau pointé par dst Original: number of bytes available in the array pointed to by dst The text has been machine-translated via Google Translate. |
| 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. |
Retourne la valeur
En cas de succès, retourne le nombre d'octets (y compris les séquences de décalage, mais à l'exclusion de la '\0' fin) écrites au tableau de caractères dont le premier élément est pointé par dst. Si dst==NULL, retourne le nombre d'octets qui ont été écrits .
Original:
On success, returns the number of bytes (including any shift sequences, but excluding the terminating '\0') written to the character array whose first element is pointed to by dst. If dst==NULL, returns the number of bytes that would have been written.
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 invalide caractère large a été rencontré), 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 wide 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 <string> #include <cwchar> void print_wide(const wchar_t* wstr) { std::mbstate_t state = std::mbstate_t(); int len = 1 + std::wcsrtombs(NULL, &wstr, 0, &state); std::vector<char> mbstr(len); std::wcsrtombs(&mbstr[0], &wstr, mbstr.size(), &state); std::cout << "multibyte string: " << &mbstr[0] << '\n' << "Length, including '\\0': " << mbstr.size() << '\n'; } int main() { std::setlocale(LC_ALL, "en_US.utf8"); // UTF-8 narrow multibyte encoding const wchar_t* wstr = L"z\u00df\u6c34\U0001d10b"; // or L"zß水𝄋" print_wide(wstr); }
Résultat :
multibyte string: zß水𝄋 Length, including '\0': 11
Voir aussi
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. (fonction) [edit] | |
convertit une chaîne de caractères multi-octets en une chaîne de caractère étroit de large, état donné Original: converts a narrow multibyte character string to wide string, given state The text has been machine-translated via Google Translate. (fonction) [edit] | |
[ virtuel Original: virtual The text has been machine-translated via Google Translate. |
convertit une chaîne de Internt à Externt, comme lors de l'écriture dans un fichier Original: converts a string from internT to externT, such as when writing to file The text has been machine-translated via Google Translate. (fonction membre virtuelle protégée de std::codecvt) [edit]
|
C documentation for wcsrtombs | |