LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME

来自cppreference.com

 
 
本地化库
语言环境方面
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
字符分类
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.
转换
Original:
Conversions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
wstring_convert(C++11)
wbuffer_convert(C++11)
小面类的基类
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.
小面类
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.
特定于语言环境的方面
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.
代码转换方面
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)
codecvt_utf8_utf16(C++11)
codecvt_mode(C++11)
C语言环境
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.
LC_ALL
LC_COLLATE
LC_CTYPE
LC_MONETARY
LC_NUMERIC
LC_TIME
 
Defined in header <clocale>
#define LC_ALL      /*implementation defined*/
#define LC_COLLATE  /*implementation defined*/
#define LC_CTYPE    /*implementation defined*/
#define LC_MONETARY /*implementation defined*/
#define LC_NUMERIC  /*implementation defined*/
#define LC_TIME     /*implementation defined*/
上面的宏常量扩展到整数常量表达式不同的值,是适合作为第一个参数的std::setlocale.
Original:
Each of the above macro constants expand to integer constant expressions with distinct values that are suitable for use as the first argument of std::setlocale.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
常数
Original:
Constant
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Explanation
LC_ALL
选择整个C语言环境
Original:
selects the entire C locale
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
LC_COLLATE
选择的C语言环境的整理分类
Original:
selects the collation category of 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.
LC_CTYPE
选择C语言环境的的字符类别划分的
Original:
selects the character classification category of 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.
LC_MONETARY
选择货币格式类别的C语言环境
Original:
selects the monetary formatting category of 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.
LC_NUMERIC
选择的数字格式类别的C语言环境
Original:
selects the numeric formatting category of 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.
LC_TIME
选择时间格式类别的C语言环境
Original:
selects the time formatting category of 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.
其他宏常量,开始与LC_的名字,然后由至少一个大写字母,可以定义在<clocale>。例如,POSIX规范要求LC_MESSAGES和GNU C库还定义LC_PAPER,LC_NAME LC_ADDRESS LC_TELEPHONE,LC_MEASUREMENT,LC_IDENTIFICATION.
Original:
Additional macro constants, with names that begin with LC_ followed by at least one uppercase letter, may be defined in <clocale>. For example, the POSIX specification requires LC_MESSAGES and the GNU C library additionally defines LC_PAPER, LC_NAME, LC_ADDRESS, LC_TELEPHONE, LC_MEASUREMENT, and LC_IDENTIFICATION.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[编辑] 为例

#include <cstdio>
#include <clocale>
#include <ctime>
#include <cwchar>
int main()
{
    std::setlocale(LC_ALL, "en_US.UTF-8"); // the C locale will be the UTF-8 enabled English
    std::setlocale(LC_NUMERIC, "de_DE");   // decimal dot will be German
    std::setlocale(LC_TIME, "ja_JP");      // date/time formatting will be Japanese
    wchar_t str[100];
    std::time_t t = std::time(NULL);
    std::wcsftime(str, 100, L"%A %c", std::localtime(&t));
    std::wprintf(L"Number: %.2f\nDate: %Ls\n", 3.14, str);
}

Output:

Number: 3,14
Date: 月曜日 2011年12月19日 18時04分40秒

[编辑] 另请参阅

获取和设置当前的C语言环境
Original:
gets and sets the current C locale
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(函数) [edit]
多态的文化差异方面的封装
Original:
set of polymorphic facets that encapsulate cultural differences
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(类) [edit]