Namespace
Varianti

std::wcrtomb

Da cppreference.com.
< cpp‎ | string‎ | multibyte

 
 
Stringhe libreria
Null-stringhe terminate
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.
Byte stringhe
Multibyte stringhe
Stringhe larghe
Classi
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
 
Stringhe multibyte null-terminated
Wide / multibyte conversioni
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
Tipi
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 );
Converte un carattere esteso alla sua rappresentazione multibyte stretta.
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.
Se s non è un puntatore nullo, la funzione determina il numero di byte necessari per memorizzare la rappresentazione di caratteri multibyte di wc (incluse le sequenze di cambio), e memorizza la rappresentazione di caratteri multibyte in array di caratteri il cui primo elemento è puntato da s. Alla maggior parte dei byte MB_CUR_MAX può essere scritto da questa funzione.
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.
Se s è un puntatore nullo, la chiamata è equivalente a std::wcrtomb(buf, L'\0', ps) per qualche buf buffer interno.
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.
Se il wc è L'\0' nulla di caratteri estesi, un byte null viene memorizzato, preceduta da una sequenza spostamento necessario per ripristinare lo stato iniziale e lo stato di spostamento *ps conversione parametro viene aggiornato per rappresentare lo stato iniziale del cambio.
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.

Indice

[modifica] Parametri

s -
puntatore ad array di caratteri ristretto in cui il carattere multibyte verrà memorizzato
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 -
il carattere esteso da convertire
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 -
puntatore all'oggetto stato di conversione quando si interpreta la stringa multibyte
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.

[modifica] Valore di ritorno

In caso di successo, restituisce il numero di byte (incluse le sequenze di cambio), scritto per l'array di caratteri il cui primo elemento è puntato da 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.
In caso di fallimento (se wc non è un carattere valido di larghezza), ritorna static_cast<std::size_t>(-1), negozi EILSEQ in errno e lascia *ps in stato specificato.
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.

[modifica] Esempio

#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);
}

Output:

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

[modifica] Vedi anche

converte un carattere esteso alla sua rappresentazione multibyte
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.

(funzione) [edit]
converte il carattere successivo multibyte a carattere esteso, determinato stato
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.

(funzione) [edit]
[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) [edit]
C documentation for wcrtomb