std::wcstombs
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. |
Déclaré dans l'en-tête <cstdlib> | ||
std::size_t wcstombs(char* dst, constwchar_t* src, std::size_t len) | ||
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 initial. Caractères convertis sont stockés dans les éléments successifs de la matrice 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 initial shift state. 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.
You can help to correct and verify the translation. Click here for instructions.
Chaque personnage est transformé comme par un appel à std::wctomb, sauf que l'état de conversion wctomb n'est pas affectée. La conversion s'arrête si:
Original:
Each character is converted as if by a call to std::wctomb, except that the wctomb's conversion state is unaffected. 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 caractère nul a été converti et mémorisé .Original:The null character was converted and stored.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Un wchar_t a été trouvé qui ne correspond pas à un caractère valide dans la locale courante C .Original:A wchar_t was found that does not correspond to a valid character in the current C locale.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 dépasse
len
.Original:The next multibyte character to be stored would exceedlen
.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Sommaire |
[modifier]Notes
Dans la plupart des implémentations, cette fonction met à jour un objet statique global de std::mbstate_t type qu'il traite par le biais de la chaîne, et ne peut pas être appelée simultanément par deux threads, std::wcsrtombs doit être utilisé dans de tels cas .
Original:
In most implementations, this function updates a global static object of type std::mbstate_t as it processes through the string, and cannot be called simultaneously by two threads, std::wcsrtombs should be used in such cases.
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.
POSIX spécifie une extension de sens: si
dst
est un pointeur NULL, cette fonction renvoie le nombre d'octets qui seraient écrites à dst
, si converti. Un comportement similaire est standard pour std::wcsrtombs .Original:
POSIX specifies a common extension: if
dst
is a null pointer, this function returns the number of bytes that would be written to dst
, if converted. Similar behavior is standard for std::wcsrtombs.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.
[modifier]Paramètres
dst | - | pointeur sur un tableau de caractère étroit où le caractère multi-octets sera stockée Original: pointer to narrow character array where the multibyte character 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 le premier élément d'une chaîne se terminant par l'échelle pour convertir Original: pointer to the first element of a null-terminated wide string to convert The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
len | - | nombre d'octets disponibles dans le tableau pointé par dst Original: number of byte 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. |
[modifier]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
.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
.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 invalide caractère large a été rencontré), renvoie static_cast<std::size_t>(-1) .
Original:
On conversion error (if invalid wide character was encountered), returns static_cast<std::size_t>(-1).
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.
[modifier]Exemple
#include <iostream>#include <clocale>#include <cstdlib> int main(){std::setlocale(LC_ALL, "en_US.utf8");// UTF-8 narrow multibyte encodingconstwchar_t* wstr = L"z\u00df\u6c34\U0001d10b";// or L"zß水𝄋"char mbstr[11]; std::wcstombs(mbstr, wstr, 11);std::cout<<"multibyte string: "<< mbstr <<'\n';}
Résultat :
multibyte string: zß水𝄋
[modifier]Voir aussi
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) | |
convertit une chaîne de caractères multi-octets en une chaîne de caractère étroit de large Original: converts a narrow multibyte character string to wide string 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 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. You can help to correct and verify the translation. Click here for instructions. (fonction membre virtuelle protégée de std::codecvt ) |
C documentation for wcstombs |