std::wstring_convert::wstring_convert
Aus 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> 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)
Konstruiert den
wstring_convert Objekt mit einem angegebenen Umwandlung Facette, mit default-rechnerisch ermittelten Werte für die Verschiebung Staat und den Fehler Strings 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)
Konstruiert den
wstring_convert Objekt mit einem angegebenen Umwandlung Facette und bestimmten Schaltzustand mit default-rechnerisch ermittelten Werte für die Fehler-Strings 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)
Konstruiert den
wstring_convert Objekt mit spezifizierter Fehler Strings mit new Codecvt wie die Umwandlung Facette und der default-konstruiert state_type als Schaltzustand .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.
Parameter
| pcvt | - | Zeiger auf die Umwandlung Facette des Typs Codecvt
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 | - | Anfangswert des Umwandlung Schaltzustand
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 | - | schmalen String auf Fehler anzuzeigen
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 | - | Widestringfelder auf Fehler anzuzeigen
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. |
Beispiel
#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"));
}