[ Web Proxy ]
URL:
Viewing: https://fr.cppreference.com/cpp/string/multibyte/wcsrtombs [Back]  [Original]

std::wcsrtombs cppreference.com
cppreference.com
Espaces de noms
Variantes

std::wcsrtombs

De cppreference.com

<metanoindex/>

 
 
Bibliothque de chanes de caractres
Chanes zro 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 chanes d'octets
Chaines multi-octets
Les chanes 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
 
Chanes zro 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
 
<tbody> </tbody>
Dclar dans l'en-tte <cwchar>
std::size_t wcsrtombs( char* dst, const wchar_t** src, std::size_t len, std::mbstate_t* ps );
Convertit une squence de caractres larges du tableau dont le premier lment est point par *src sa reprsentation multi-octets troite qui commence dans l'tat de conversion dcrite par *ps. Si dst n'est pas nulle, les caractres convertis sont stocks dans les lments successifs du tableau de caractres pointe 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'arrte 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 caractre nul a t transform et stock. src est rgl sur NULL et *ps reprsente 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 caractre valide dans la locale courante C. src est configur pour pointer sur le premier caractre 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 caractre multi-octets suivant mmoriser serait len dpasser. src est configur pour pointer sur le premier caractre large non converti. Cette condition n'est pas vrifie 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.

Paramtres

dst -
pointeur sur un tableau de caractre troit o les caractres multi-octets sera stocke
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 lment d'une chane 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.

Retourne la valeur

En cas de succs, retourne le nombre d'octets (y compris les squences de dcalage, mais l'exclusion de la '\0' fin) crites au tableau de caractres dont le premier lment 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 caractre large a t rencontr), 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 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);
}

Rsultat :

multibyte string: z
Length, including '\0': 11

Voir aussi

convertit le caractre large de sa reprsentation 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 chane de caractres multi-octets en une chane de caractre 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 chane 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 protge de std::codecvt) [edit]
C documentation for wcsrtombs

Web Proxy Viewer  |  New URL  |  Original Page