Espaces de noms
Variantes
Affichages
Actions

std::wcrtomb

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
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 wcrtomb( char* s, wchar_t wc, std::mbstate_t* ps );
Convertit un caractère large dans sa représentation multi-octets étroite .
Original:
Converts a wide character to its narrow multibyte representation.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Si s n'est pas un pointeur NULL, la fonction détermine le nombre d'octets nécessaires pour stocker la représentation des caractères multi-octets wc (y compris les séquences de décalage), et stocke la représentation caractères multi-octets dans le tableau de caractères dont le premier élément est pointé par s. À la plupart des MB_CUR_MAX octets peuvent être écrits par cette fonction .
Original:
If s is not a null pointer, the function determines the number of bytes necessary to store the multibyte character representation of wc (including any shift sequences), and stores the multibyte character representation in the character array whose first element is pointed to by s. At most MB_CUR_MAX bytes can be written by this function.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Si s est un pointeur NULL, l'appel est équivalent à std::wcrtomb(buf, L'\0', ps) pour certains buf tampon interne .
Original:
If s is a null pointer, the call is equivalent to std::wcrtomb(buf, L'\0', ps) for some internal buffer buf.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Si wc est la L'\0' caractère large nul, un octet nul est stocké, précédée par une séquence de décalage nécessaire pour rétablir l'état initial et l'état *ps paramètre de conversion est mis à jour pour représenter l'état initial .
Original:
If wc is the null wide character L'\0', a null byte is stored, preceded by any shift sequence necessary to restore the initial shift state and the conversion state parameter *ps is updated to represent 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.

Sommaire

[modifier] Paramètres

s -
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.
wc -
le caractère large à convertir
Original:
the wide character to convert
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 utilisé pour interpréter la chaîne multi-octets
Original:
pointer to the conversion state object used when interpreting the multibyte string
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) écrit au tableau de caractères dont le premier élément est pointé par s .
Original:
On success, returns the number of bytes (including any shift sequences) written to the character array whose first element is pointed to by s.
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'échec (si wc n'est pas un caractère valide de large), les rendements static_cast<std::size_t>(-1), les magasins EILSEQ dans errno, et laisse dans un état indéterminé *ps .
Original:
On failure (if wc is not a valid wide character), 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 <clocale>
#include <string>
#include <cwchar>
 
void print_wide(const std::wstring& wstr)
{
    std::mbstate_t state = std::mbstate_t();
    for(wchar_t wc : wstr) {
        std::string mb(MB_CUR_MAX, '\0');
        int ret = std::wcrtomb(&mb[0], wc, &state);
        std::cout << "multibyte char " << mb << " is " << ret << " bytes\n";
    }
}
 
int main()
{
    std::setlocale(LC_ALL, "en_US.utf8");
    // UTF-8 narrow multibyte encoding
    std::wstring wstr = L"z\u00df\u6c34\U0001d10b"; // or L"zß水𝄋"
    print_wide(wstr);
}

Résultat :

multibyte char z is 1 bytes
multibyte char ß is 2 bytes
multibyte char 水 is 3 bytes
multibyte char 𝄋 is 4 bytes

[modifier] Voir aussi

convertit le caractère large de sa représentation multi-octets
Original:
converts a wide character to its multibyte representation
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 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]
[
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) [edit]
C documentation for wcrtomb