std::wstring_convert::wstring_convert
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> wstring_convert( Codecvt* pcvt = new Codecvt ); |
(1) | |
wstring_convert( Codecvt* pcvt, state_type state); |
(2) | |
wstring_convert( const byte_string& byte_err, const wide_string& wide_err = wide_string() ); |
(3) | |
1)
Costruisce l'oggetto
wstring_convert con una sfaccettatura di conversione specificato, utilizzando i valori di default-costruiti per lo stato del cambio e le stringhe di errore Original:
Constructs the
wstring_convert object with a specified conversion facet, using default-constructed values for the shift state and the error strings 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.
2)
Costruisce l'oggetto
wstring_convert con un aspetto di conversione specificato e stato di spostamento specificato, utilizzando di default-costruiti i valori per le stringhe di errore Original:
Constructs the
wstring_convert object with a specified conversion facet and specified shift state, using default-constructed values for the error strings 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.
3)
Costruisce l'oggetto
wstring_convert con stringhe di errore specificati, utilizzando new Codecvt come la faccetta conversione e di default costruito state_type come stato del cambio.Original:
Constructs the
wstring_convert object with specified error strings, using new Codecvt as the conversion facet and the default-constructed state_type as shift 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.
Parametri
| pcvt | - | puntatore alla faccetta Codecvt conversione di tipo
Original: pointer to the conversion facet of type Codecvt The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| state | - | valore iniziale dello stato spostamento di conversione
Original: initial value of the conversion shift state The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| byte_err | - | stringa stretta per visualizzare in caso di errori
Original: narrow string to display on errors The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| wide_err | - | stringa ampio per visualizzare in caso di errori
Original: wide string to display on errors The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Esempio
#include <locale>
#include <utility>
#include <codecvt>
// utility wrapper to adapt locale-bound facets for wstring/wbuffer convert
template<class Facet>
struct deletable_facet : Facet
{
template<class ...Args>
deletable_facet(Args&& ...args) : Facet(std::forward<Args>(args)...) {}
~deletable_facet() {}
};
int main()
{
// UTF-16le / UCS4 conversion
std::wstring_convert<std::codecvt_utf16<char32_t, 0x10ffff, std::little_endian>> u16to32;
// UTF-8 / wide string conversion with custom messages
std::wstring_convert<std::codecvt_utf8<wchar_t>> u8towide("Error!", L"Error!");
// GB18030 / wide string conversion facet
typedef deletable_facet<std::codecvt_byname<wchar_t, char, std::mbstate_t>> F;
std::wstring_convert<F> gbtowide(new F("zh_CN.gb18030"));
}