std::wcsrtombs
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. |
<metanoindex/>
<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.
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.
You can help to correct and verify the translation. Click here for instructions.
- Le caractre nul a t transform et stock.
srcest rgl sur NULL et*psreprsente 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 caractre valide dans la locale courante C.srcest configur pour pointer sur le premier caractre large non converti .Original:Awchar_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 caractre multi-octets suivant mmoriser serait
lendpasser.srcest configur pour pointer sur le premier caractre large non converti. Cette condition n'est pas vrifie sidst==NULL.Original:the next multibyte character to be stored would exceedlen.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.
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.
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.
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) | |
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) | |
[ 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)
|
C documentation for wcsrtombs
| |