gpt4 book ai didi

c++ - 为什么在 OSX 上语言环境没有改变?

转载 作者:行者123 更新时间:2023-11-30 04:32:06 25 4
gpt4 key购买 nike

我正在尝试在 Mac 上使用 strftime 以依赖于语言环境的方式输出时间。

我正在设置语言环境并获取时间:

// sets the program's locale to the native locale
// without this line the locale is 'C'

log.debug(setlocale(LC_ALL,""));
struct tm* date = localtime(&time);
strftime(result.buf, size, "%X %x", date);
log.debug(result.buf);

哪些输出

en_GB.UTF-8
13:58:01 25/10/2011

这是正确的。但是,我随后转到语言和文本系统首选项面板,并将区域更改为美国。如果我再次运行我的程序,我会得到相同的语言环境,并且时间的格式也相同(我希望语言环境为 en_US 并且日期格式为 10/25/2011)。我做错了什么?

最佳答案

您需要重新启动终端或任何您启动程序的程序才能使更改生效。

关于c++ - 为什么在 OSX 上语言环境没有改变?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7889700/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com