std::locale::name

来自cppreference.com
< cpp‎ | locale‎ | locale
 
 
本地化库
本地环境与平面
本地环境
平面类别基类
ctype(字符类别)平面
numeric(数值)平面
collate(对照比较)平面
time(时间)平面
monetary(货币)平面
messages(消息)平面
字符分类与转换
字符分类
转换
编码转换平面
(C++11)    
C 本地环境
 
 
在标头 <locale> 定义
std::string name() const;

返回操作系统所知的 locale 名称,例如 "POSIX" 或 "en_US.UTF8" 或 "English_United States.1252" 。若该 locale 不是系统提供的本地环境,则返回字符串 "*" 。

返回值

locale 的名称,或若无名则为 "*" 。

示例

#include <locale>
#include <iostream>
#include <string>
 
int main()
{
    std::locale loc(std::locale(), new std::ctype<char>);
    std::cout << "The default locale is " << std::locale().name() << '\n'
              << "The user's locale is " << std::locale("").name() << '\n'
              << "A nameless locale is " << loc.name() << '\n';
}

可能的输出:

The default locale is C
The user's locale is en_US.UTF8
A nameless locale is *

参阅

构造新的 locale
(公开成员函数)