Namespace
Varianti

std::mbrtowc

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 mbrtowc( wchar_t* pwc,

                     const char* s,
                     std::size_t n,

                     std::mbstate_t* ps );
Converte un carattere multibyte stretto a un carattere ampio.
Original:
Converts a narrow multibyte character to a wide character.
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, controlla la maggior parte a byte n della stringa di caratteri multibyte, a cominciare con il byte puntato da s per determinare il numero di byte necessari per completare il carattere successivo multibyte (incluse le sequenze di cambio). Se la funzione determina che il carattere multibyte successivo s sia completo e valido, lo converte il carattere corrispondente ampia e lo memorizza in *pwc (se pwc non è nullo).
Original:
If s is not a null pointer, inspects at most n bytes of the multibyte character string, beginning with the byte pointed to by s to determine the number of bytes necessary to complete the next multibyte character (including any shift sequences). If the function determines that the next multibyte character in s is complete and valid, converts it to the corresponding wide character and stores it in *pwc (if pwc is not null).
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, i valori di n e pwc vengono ignorati e chiamata è equivalente a std::mbrtowc(NULL, "", 1, ps).
Original:
If s is a null pointer, the values of n and pwc are ignored and call is equivalent to std::mbrtowc(NULL, "", 1, ps).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Se il carattere largo prodotto è il carattere nullo, lo stato di conversione memorizzate nel *ps è lo stato iniziale del cambio.
Original:
If the wide character produced is the null character, the conversion state stored in *ps is 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

pwc -
puntatore nella posizione in cui il personaggio risultante gamma verrà scritto
Original:
pointer to the location where the resulting wide character will be written
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
s -
puntatore alla stringa di caratteri multibyte utilizzati come input
Original:
pointer to the multibyte character string used as input
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
n -
limitare il numero di byte in s che può essere esaminato
Original:
limit on the number of bytes in s that can be examined
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ps -
puntatore allo stato di conversione quando si interpreta la stringa multibyte
Original:
pointer to the conversion state 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

La prima delle seguenti che vale:
Original:
The first of the following that applies:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • 0 se il carattere convertito da s (e conservato in pwc se non nullo) è stato il carattere null
    Original:
    0 if the character converted from s (and stored in pwc if non-null) was the null character
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • il numero di byte [1...n] del carattere multibyte correttamente convertito da s
    Original:
    the number of bytes [1...n] of the multibyte character successfully converted from s
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • static_cast<std::size_t>(-2) se i byte n prossimi costituiscono un incompleto, ma finora valido, caratteri multibyte. Nulla è scritto *pwc.
    Original:
    static_cast<std::size_t>(-2) if the next n bytes constitute an incomplete, but so far valid, multibyte character. Nothing is written to *pwc.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • static_cast<std::size_t>(-1) se si verifica errore di codifica. Nulla viene scritto *pwc, il EILSEQ valore viene memorizzato nella errno e il valore di *ps è lasciato non specificato.
    Original:
    static_cast<std::size_t>(-1) if encoding error occurs. Nothing is written to *pwc, the value EILSEQ is stored in errno and the value of *ps is left unspecified.
    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 <cstring>
#include <cwchar>
 
void print_mb(const char* ptr)
{
    std::mbstate_t state = std::mbstate_t(); // initial state
    const char* end = ptr + std::strlen(ptr);
    int len;
    wchar_t wc;
    while((len = std::mbrtowc(&wc, ptr, end-ptr, &state)) > 0) {
        std::wcout << "Next " << len << " bytes are the character " << wc << '\n';
        ptr += len;
    }
}
 
int main()
{
    std::setlocale(LC_ALL, "en_US.utf8");
    // UTF-8 narrow multibyte encoding
    const char* str = u8"z\u00df\u6c34\U0001d10b"; // or u8"zß水𝄋"
                      // or "\x7a\xc3\x9f\xe6\xb0\xb4\xf0\x9d\x84\x8b";
    print_mb(str);
}

Output:

Next 1 bytes are the character z
Next 2 bytes are the character ß
Next 3 bytes are the character 水
Next 4 bytes are the character 𝄋

[modifica] Vedi anche

converte il carattere successivo multibyte a carattere esteso
Original:
converts the next multibyte character to wide character
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 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) [edit]
[virtuale]
converte una stringa da externT a internt, come ad esempio durante la lettura dal file
Original:
converts a string from externT to internT, such as when reading from 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 mbrtowc