Namensräume
Varianten
Aktionen

std::codecvt::encoding, std::codecvt::do_encoding

Aus cppreference.com
< cpp‎ | locale‎ | codecvt

 
 
Lokalisierungen Bibliothek
Locales und Facetten
Original:
Locales and facets
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
locale
Buchstaben-Klassifikation
Original:
Character classification
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Conversions
Original:
Conversions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Facet Kategorie Basisklassen
Original:
Facet category base classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Facet Kategorien
Original:
Facet categories
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Locale-spezifische Facetten
Original:
Locale-specific facets
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Code-Konvertierung Facetten
Original:
Code conversion facets
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
codecvt_utf8(C++11)
codecvt_utf16(C++11)
C locale
Original:
C locale
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
 
 
Defined in header <locale>
public:
int encoding() const
(1)
protected:
int do_encoding() const
(2)
1)
öffentliche Member-Funktion ruft die Member-Funktion do_encoding der am meisten abgeleiteten Klasse .
Original:
public member function, calls the member function do_encoding of the most derived class.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

2) if the encoding represented by this codecvt facet maps each internal character to the same, constant number of external characters, returns that number. If the encoding is variable-length (e.g. UTF-8 or UTF-16), returns 0. If the encoding is state-dependent, returns -1.

Inhaltsverzeichnis

[Bearbeiten] Rückgabewert

The exact number of externT characters that correspond to one internT character, if constant. 0 if the number varies, -1 if the encoding is state-dependent.

Die nicht-Converting-Spezialisierung std::codecvt<char, char, std::mbstate_t> kehrt 1
Original:
The non-converting specialization std::codecvt<char, char, std::mbstate_t> returns 1
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[Bearbeiten] Ausnahmen

noexcept specification:  
noexcept
  (seit C++11)

[Bearbeiten] Beispiel

#include <locale>
#include <iostream>
int main()
{
    std::cout << "en_US.utf8 is a variable-length encoding, encoding() returns "
              << std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t>>(
                    std::locale("en_US.utf8")
              ).encoding() << '\n';
 
    std::cout << "zh_CN.gb18030 is also variable-length, encoding() == "
              << std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t>>(
                    std::locale("zh_CN.gb18030")
              ).encoding() << '\n';
 
    std::cout << "ru_RU.koi8r is a single-byte encoding encoding() == "
              << std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t>>(
                    std::locale("ru_RU.koi8r")
              ).encoding() << '\n';
}

Output:

en_US.utf8 is a variable-length encoding, encoding() returns 0
zh_CN.gb18030 is also variable-length, encoding() == 0
ru_RU.koi8r is a single-byte encoding encoding() == 1

[Bearbeiten] Siehe auch

MB_CUR_MAX
maximale Anzahl von Bytes in einer Multibyte-Zeichen in der aktuellen C locale
(Makro-Variablen)
Original:
maximum number of bytes in a multibyte character in the current C locale
(Makro-Variablen)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
[edit]
[virtuell]
gibt die maximale Anzahl von externT Zeichen, die in einem einzigen Internt Zeichen umgewandelt werden konnte
Original:
returns the maximum number of externT characters that could be converted into a single internT character
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(virtuellen geschützten Member-Funktion) [edit]