首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

LC_ALL

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...

Constant

Explanation

LC_ALL

selects the entire C locale

LC_COLLATE

selects the collation category of the C locale

LC_CTYPE

selects the character classification category of the C locale

LC_MONETARY

selects the monetary formatting category of the C locale

LC_NUMERIC

selects the numeric formatting category of the C locale

LC_TIME

selects the time formatting category of the C locale

其他宏常量,名称以LC_后面至少有一个大写字母,可以在<clocale>例如,POSIX规范要求LC。[医]消息%28控制std::perrorstd::strerror%29而且GNU C库还定义了LC[医]纸,LC[医]名称,LC[医]地址,LC[医]电话,LC[医]测量和LC[医]身份识别。

二次

代码语言:javascript
复制
#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(nullptr);
    std::wcsftime(str, 100, L"%A %c", std::localtime(&t));
    std::wprintf(L"Number: %.2f\nDate: %Ls\n", 3.14, str);
}

二次

产出:

二次

代码语言:javascript
复制
Number: 3,14
Date: 月曜日 2011年12月19日 18時04分40秒

二次

另见

setlocale

gets and sets the current C locale (function)

locale

set of polymorphic facets that encapsulate cultural differences (class)

C地区类别的文档

代码语言:txt
复制
 © cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券