获取当前在C ++中设置的全局区域设置? [英] Get the global locale that is currently set in C++?

查看:147
本文介绍了获取当前在C ++中设置的全局区域设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C ++中,我可以像这样 设置当前语言环境:

In C++, I can set the current locale like this:

std::locale::global(std::locale(name))

/ em>当前全局语言环境?

But how can I get the current global locale?

在我的代码中,我需要获取当前语言环境,将其保存为tmp var,将全局语言环境设置为其他语言,输出内容,然后将其设置回

In my code, I need to get the current locale, save it to a tmp var, set the global locale to something else, output something, then set it back to the previous locale.

推荐答案

如果你调用 std :: locale ,你会得到它。

If you call the default constructor of std::locale, you get it.

std::locale the_global_locale; // <-- automatically correct to std::locale::global
                               //     or a copy of std::locale::classic

更多信息: http://en.cppreference。 com / w / cpp / locale / locale / locale

这篇关于获取当前在C ++中设置的全局区域设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆