std::locale::name

来自cppreference.com
< cpp‎ | locale‎ | locale
定义于头文件 <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
(公开成员函数)