std::locale – cppreference.com
Aus cppreference.com
<metanoindex/>
<tbody> </tbody>
| definiert in Header <locale> |
||
|
|
||
Ein Objekt der Klasse std::locale ist eine indizierte Gruppe von Referenz-gezählt Zeiger auf Facetten. Jeder Stream-Objekt der C + + Input / Output-Bibliothek wird mit einem std::locale verbunden und nutzt seinen Facetten zum Parsen und Formatieren der Daten. Zusätzlich wird ein Gebietsschema Objekts mit jedem Objekt zugeordnet basic_regex. Locale-Objekte können auch als Prädikate, die String-Sortierung durchzuführen mit den Standard-Containern und Algorithmen und kann direkt zugegriffen werden, um zu erhalten oder ändern Sie die Facetten halten sie verwendet werden .
Original:
An object of class std::locale is an indexed set of reference-counted pointers to facets. Each stream object of the C++ input/output library is associated with an std::locale and uses its facets for parsing and formatting of all data. In addition, a locale object is associated with each basic_regex object. Locale objects can also be used as predicates that perform string collation with the standard containers and algorithms and can be accessed directly to obtain or modify the facets they hold.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Jeder Sprachumgebung in einem C + + Programm aufgebaut hält mindestens die folgenden Standard-Facetten, sondern ein Programm zusätzliche Spezialisierungen oder ganz neue Facetten zu definieren und sie in jede bestehende Locale Objekt .
Original:
Each locale constructed in a C++ program holds at least the following standard facets, but a program may define additional specializations or completely new facets and add them to any existing locale object.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
| Supported facets | |
|---|---|
std::collate<char>
|
std::collate<wchar_t>
|
std::ctype<char>
|
std::ctype<wchar_t>
|
std::codecvt<char,char,mbstate_t>std::codecvt<char16_t,char,mbstate_t>
|
std::codecvt<char32_t,char,mbstate_t>std::codecvt<wchar_t,char,mbstate_t>
|
std::moneypunct<char> std::moneypunct<char,true>
|
std::moneypunct<wchar_t>std::moneypunct<wchar_t,true>
|
std::money_get<char>
|
std::money_get<wchar_t>
|
std::money_put<char>
|
std::money_put<wchar_t>
|
std::numpunct<char>
|
std::numpunct<wchar_t>
|
std::num_get<char>
|
std::num_get<wchar_t>
|
std::num_put<char>
|
std::num_put<wchar_t>
|
std::time_get<char>
|
std::time_get<wchar_t>
|
std::time_put<char>
|
std::time_put<wchar_t>
|
std::messages<char>
|
std::messages<wchar_t>
|
Mitglied Typen
die Facette Indextyp: jede Facette Klasse deklarieren muss oder erben ein öffentliches statisches Element dieses Typs Original: the facet index type: each facet class must declare or inherit a public static member of this type The text has been machine-translated via Google Translate. (Klasse) [edit] | |
die Basisklasse für alle Facetten Kategorien: jede Facette jeder Kategorie wird von diesem Typ abgeleitet Original: the base class for all facet categories: each facet of any category is derived from this type The text has been machine-translated via Google Translate. (Klasse) [edit] | |
category |
int (typedef) |
Mitglied widerspricht
none [statisch] |
ein Nullwert des Typs Original: a zero value of type The text has been machine-translated via Google Translate. (public static Mitglied konstanten) |
collate [statisch] |
eine Bitmaske vom Typ Original: a bitmask value of type The text has been machine-translated via Google Translate. (public static Mitglied konstanten) |
ctype [statisch] |
eine Bitmaske vom Typ Original: a bitmask value of type The text has been machine-translated via Google Translate. (public static Mitglied konstanten) |
monetary [statisch] |
eine Bitmaske vom Typ Original: a bitmask value of type The text has been machine-translated via Google Translate. (public static Mitglied konstanten) |
numeric [statisch] |
eine Bitmaske vom Typ Original: a bitmask value of type The text has been machine-translated via Google Translate. (public static Mitglied konstanten) |
time [statisch] |
eine Bitmaske vom Typ Original: a bitmask value of type The text has been machine-translated via Google Translate. (public static Mitglied konstanten) |
messages [statisch] |
eine Bitmaske vom Typ Original: a bitmask value of type The text has been machine-translated via Google Translate. (public static Mitglied konstanten) |
all [statisch] |
collate | ctype | monetary | numeric | time | messages (public static Mitglied konstanten) |
Member-Funktionen
baut eine neue locale Original: constructs a new locale The text has been machine-translated via Google Translate. (öffentliche Elementfunktion) [edit] | |
zerstört sich das Gebietsschema und die Facetten, deren Referenzzähler Null wird Original: destructs the locale and the facets whose reference count becomes zero The text has been machine-translated via Google Translate. (öffentliche Elementfunktion) [edit] | |
ersetzt eine locale Original: replaces a locale The text has been machine-translated via Google Translate. (öffentliche Elementfunktion) [edit] | |
konstruiert eine Locale mit Kompilierzeit erkannt Facette von einem anderen Gebietsschema kopiert Original: constructs a locale with compile-time identified facet copied from another locale The text has been machine-translated via Google Translate. (öffentliche Elementfunktion) [edit] | |
gibt den Namen des Lokals oder "*", wenn unbenannt Original: returns the name of the locale or "*" if unnamed The text has been machine-translated via Google Translate. (öffentliche Elementfunktion) [edit] | |
Gleichheit Vergleich zwischen locale Objekte Original: equality comparison between locale objects The text has been machine-translated via Google Translate. (öffentliche Elementfunktion) [edit] | |
| lexicographically compares two strings using this locale's collate facet (öffentliche Elementfunktion) [edit] | |
[statisch] |
ändert die globale locale Original: changes the global locale The text has been machine-translated via Google Translate. (public static Elementfunktion) [edit] |
[statisch] |
erhält einen Verweis auf die "C"-Locale Original: obtains a reference to the "C" locale The text has been machine-translated via Google Translate. (public static Elementfunktion) [edit] |
Beispiel
Demonstriert die typischen Prolog eines locale-sensitive Programm (Cross-Plattform)
Original:
Demonstrates the typical prologue of a locale-sensitive program (cross-platform)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
#include <iostream> #include <locale> int main() { std::wcout << "User-preferred locale setting is " << std::locale("").name().c_str() << '\n'; // on startup, the global locale is the "C" locale std::wcout << 1000.01 << '\n'; // replace the C++ global locale as well as the C locale with the user-preferred locale std::locale::global(std::locale("") ); // use the new global locale for future wide character output std::wcout.imbue(std::locale()); // output the same number again std::wcout << 1000.01 << '\n'; }
Output:
User-preferred locale setting is en_US.UTF8 1000.01 1,000.01
Siehe auch
erhält eine Facette von einem locale Original: obtains a facet from a locale The text has been machine-translated via Google Translate. (Funktions-Template) [edit] | |
prüft, ob eine locale implementiert eine spezielle Facette Original: checks if a locale implements a specific facet The text has been machine-translated via Google Translate. (Funktions-Template) [edit] | |
setzt locale Original: sets locale The text has been machine-translated via Google Translate. (öffentliche Elementfunktion of std::ios_base) [edit]
| |
kehrt momentanen Locale Original: returns current locale The text has been machine-translated via Google Translate. (öffentliche Elementfunktion of std::ios_base) [edit]
| |