std::locale
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>| Elemento definito nell'header <locale>
|
||
class locale; |
||
Un oggetto di std::locale classe è un insieme indicizzato di puntatori di riferimento contati a sfaccettature. Ogni oggetto flusso del C + + ingresso / uscita della libreria è associato ad un std::locale e utilizza le sue sfaccettature per l'analisi e la formattazione di tutti i dati. Inoltre, un oggetto locale viene associato a ciascun oggetto basic_regex. Oggetti Locale può essere utilizzato anche come predicati che eseguono confronto stringa con i contenitori standard e gli algoritmi e si può accedere direttamente per ottenere o modificare le sfaccettature in loro possesso.
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.
You can help to correct and verify the translation. Click here for instructions.
Ogni locale costruito in un programma C + + contiene almeno i seguenti aspetti standard, ma un programma può definire ulteriori specializzazioni o sfaccettature completamente nuove e aggiungerli a qualsiasi oggetto esistente locale.
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.
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>
|
Membri tipi
il tipo di indice faccetta: ogni classe sfaccettatura deve dichiarare o ereditare un membro statico pubblico di questo tipo 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. You can help to correct and verify the translation. Click here for instructions. (classe) | |
la classe di base per tutte le categorie di facet: ogni aspetto di qualsiasi categoria è derivato da questo tipo 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. You can help to correct and verify the translation. Click here for instructions. (classe) | |
category |
int (typedef) |
Membri oggetti
none [statico] |
un valore nullo di tipo category indica nessuna categoria aspetto Original: a zero value of type category indicating no facet category The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (pubblico membro statico costante) |
collate [statico] |
un valore di maschera di bit di category tipo che indica la categoria aspetto di fascicolazione Original: a bitmask value of type category indicating the collate facet category The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (pubblico membro statico costante) |
ctype [statico] |
un valore di maschera di bit di category tipo che indica la categoria CType sfaccettatura Original: a bitmask value of type category indicating the ctype facet category The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (pubblico membro statico costante) |
monetary [statico] |
un valore di maschera di bit di category tipo che indica la categoria aspetto monetario Original: a bitmask value of type category indicating the monetary facet category The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (pubblico membro statico costante) |
numeric [statico] |
un valore di maschera di bit di category tipo che indica la categoria numerica sfaccettatura Original: a bitmask value of type category indicating the numeric facet category The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (pubblico membro statico costante) |
time [statico] |
un valore di maschera di bit di category tipo che indica la categoria sfaccettatura tempo Original: a bitmask value of type category indicating the time facet category The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (pubblico membro statico costante) |
messages [statico] |
un valore di maschera di bit che indica il tipo di category aspetto messaggi categoria Original: a bitmask value of type category indicating the messages facet category The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (pubblico membro statico costante) |
all [statico] |
collate | ctype | monetary | numeric | time | messages (pubblico membro statico costante) |
Membri funzioni
costruisce un nuovo locale Original: constructs a new locale The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (metodo pubblico) | |
distrugge il locale e gli aspetti cui riferimento conteggio diventa zero Original: destructs the locale and the facets whose reference count becomes zero The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (metodo pubblico) | |
sostituisce un locale Original: replaces a locale The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (metodo pubblico) | |
costruisce un locale con in fase di compilazione aspetto identificato copiato da un altro locale Original: constructs a locale with compile-time identified facet copied from another locale The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (metodo pubblico) | |
restituisce il nome del locale o "*" se senza nome Original: returns the name of the locale or "*" if unnamed The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (metodo pubblico) | |
confronto di uguaglianza tra gli oggetti delle impostazioni internazionali Original: equality comparison between locale objects The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (metodo pubblico) | |
| lexicographically compares two strings using this locale's collate facet (metodo pubblico) | |
[statico] |
cambia il locale globale Original: changes the global locale The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (metodo pubblico statico) |
[statico] |
ottiene un riferimento al locale "C" Original: obtains a reference to the "C" locale The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (metodo pubblico statico) |
Esempio
Viene illustrato il prologo tipico di un locale-sensitive programma (cross-platform)
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.
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
Vedi anche
ottiene un aspetto da un locale Original: obtains a facet from a locale The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (funzione di modello) | |
Verifica se un locale implementa un determinato aspetto Original: checks if a locale implements a specific facet The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (funzione di modello) | |
imposta locale Original: sets locale The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (metodo pubblico) | |
restituisce locale corrente Original: returns current locale The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (metodo pubblico) | |