比如说,我可以使用 _create_locale 从我的 C 程序设置区域设置像这样:
localeUS = _create_locale(LC_ALL, "English_United States.1252");
但我需要的是相反的,即检索调用线程的区域设置名称(上面函数的第二个参数)。知道如何做到这一点吗?
PS。我知道现代 Windows 使用 LCID。我需要此区域设置名称以与旧代码兼容。最佳答案
希望您能够使用标准 C++。
示例
#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 *
关于c++ - 如何获取我的线程的区域设置名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16431220/