Espaces de noms
Variantes
Affichages
Actions

std::wcsrtombs

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
wctomb
wcstombs
wctob
wcrtomb
wcsrtombs
c16rtomb (C++11)
c32rtomb (C++11)
mbrlen
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 wcsrtombs( char* dst,

                       const wchar_t** src,
                       std::size_t len,

                       std::mbstate_t* ps );
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é. src est réglé sur NULL et *ps représente l'état initial .
    Original:
    The 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 wchar_t a été trouvé qui ne correspond pas à un caractère valide dans la locale courante C. src est configuré pour pointer sur le premier caractère large non converti .
    Original:
    A wchar_t was found that does not correspond to a valid character in the current C locale. src is 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 len dépasser. src est configuré pour pointer sur le premier caractère large non converti. Cette condition n'est pas vérifiée si dst==NULL .
    Original:
    the next multibyte character to be stored would exceed len. src is set to point at the first unconverted wide 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.

Sommaire

[modifier] 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.
You can help to correct and verify the translation. Click here for instructions.
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.
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 bytes 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.

[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. 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.

[modifier] 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

[modifier] 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.
You can help to correct and verify the translation. Click here for instructions.

(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.
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 wcsrtombs