如何获得语言环境名称为我的线程

How to get the locale name for my thread?

本文关键字:我的 线程 何获得 语言 环境      更新时间:2023-10-16

比如说,我可以在我的C程序中使用_create_locale设置语言环境,如下所示:

localeUS = _create_locale(LC_ALL, "English_United States.1252");

但是我需要的是相反的,即为调用线程检索区域名称(上述函数的第二个参数)。知道怎么做吗?

p。我知道现代Windows使用lcd。为了与旧代码兼容,我需要这个区域设置名称。

希望你能使用标准c++。

从std::语言环境::名称:

例子
#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 *