在C++中,我可以像这样设置当前的语言环境:
std::locale::global(std::locale(name))
Run Code Online (Sandbox Code Playgroud)
但是,我如何获得当前的全局区域设置?
在我的代码中,我需要获取当前的语言环境,将其保存到tmp var,将全局语言环境设置为其他内容,输出内容,然后将其设置回以前的语言环境.
ipc*_*ipc 14
如果你调用默认构造函数std::locale,你就可以得到它.
std::locale the_global_locale; // <-- automatically correct to std::locale::global
// or a copy of std::locale::classic
Run Code Online (Sandbox Code Playgroud)
更多信息请访问:http://en.cppreference.com/w/cpp/locale/locale/locale
它的返回值是旧的语言环境,所以只需使用它.
locale l = locale::global(locale(name));
//do some stuff here
locale::global(l);
Run Code Online (Sandbox Code Playgroud)
编辑:有用:http://en.cppreference.com/w/cpp/locale/locale/global
| 归档时间: |
|
| 查看次数: |
6774 次 |
| 最近记录: |