std::wcsrtombs
Da cppreference.com.
|
|
Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate.
La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
<metanoindex/>
<tbody> </tbody>| Elemento definito nell'header <cwchar>
|
||
std::size_t wcsrtombs( char* dst, const wchar_t** src, std::size_t len, std::mbstate_t* ps ); |
||
Converte una sequenza di caratteri estesi dalla matrice il cui primo elemento è puntato da
*src alla sua rappresentazione multibyte stretta che inizia nello stato di conversione descritto da *ps. Se dst non è nullo, i caratteri convertiti vengono memorizzati negli elementi successivi della matrice char puntato da dst. Non più di byte len vengono scritti nella matrice di destinazione.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.
Ogni carattere viene convertito come per una chiamata a std::wcrtomb. La conversione si interrompe se:
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.
- Il carattere null è stato convertito e memorizzato.
srcè impostato su NULL*pse rappresenta lo stato iniziale del cambio.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_tè accertato che non corrisponde a un carattere valido nella versione locale corrente C.srcè impostato per puntare al primo carattere non convertito ampio.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. - il carattere multibyte successivo da memorizzare sarebbe
lensuperare.srcè impostato per puntare al primo carattere non convertito di larghezza. Questa condizione non è verificata sedst==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.
Parametri
| dst | - | puntatore a matrice di caratteri stretta dove i caratteri multibyte verrà memorizzato
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 | - | puntatore al puntatore al primo elemento di una stringa con terminazione null di larghezza
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 | - | numero di byte disponibili nell'array puntato da 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 | - | puntatore all'oggetto stato di conversione
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. |
Valore di ritorno
In caso di successo, restituisce il numero di byte (comprese le sequenze di cambio, ma escluso il
'\0' finale) scritte per l'array di caratteri il cui primo elemento è puntato da dst. Se dst==NULL, restituisce il numero di byte che sarebbero stati scritti.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.
In caso di errore di conversione (se non valido caratteri larghi veniva rilevato), ritorna
static_cast<std::size_t>(-1), negozi EILSEQ in errno e lascia *ps in stato specificato.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.
Esempio
#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);
}
Output:
multibyte string: zß水𝄋
Length, including '\0': 11
Vedi anche
converte un carattere esteso alla sua rappresentazione multibyte, determinato stato 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. (funzione) | |
converte una stringa di caratteri multibyte stretta alla stringa di larghezza, determinato stato 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. (funzione) | |
[virtuale] |
converte una stringa da internt a externT, come ad esempio durante la scrittura su file 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. (virtuale protetto funzione of std::codecvt membro)
|
C documentation for wcsrtombs
| |