gpt4 book ai didi

java - Java 中用于小写 HTTP 值的区域设置

转载 作者:行者123 更新时间:2023-12-01 18:44:13 26 4
gpt4 key购买 nike

当用户的默认区域设置为土耳其语时,i 会小写为 ı。这是有问题的,因为我想在我的 Accept-Language header 中包含用户的语言和国家/地区代码,但是 OkHttp only allows ASCII header values 。我意识到 Accept-Language 历来不区分大小写,但我必须与不属于我的服务器交互,该服务器需要仅小写的 Accept-Language header 值(value)观。对于像这样的仅机器小写,我应该使用什么区域设置?

最佳答案

我还没有找到任何官方 Java 文档讨论保证机器不变的小写行为。

Apple's documentation谈论 en_US_POSIX:

If you're working with fixed-format dates, you should first set the locale of the date formatter to something appropriate for your fixed format. In most cases the best locale to choose is en_US_POSIX, a locale that's specifically designed to yield US English results regardless of both user and system preferences. en_US_POSIX is also invariant in time (if the US, at some point in the future, changes the way it formats dates, en_US will change to reflect the new behavior, but en_US_POSIX will not), and between platforms (en_US_POSIX works the same on iPhone OS as it does on OS X, and as it does on other platforms).

en_US_POSIX 在 Java 中可用 new Locale("en", "US", "POSIX")。我不知道这有什么保证。

关于java - Java 中用于小写 HTTP 值的区域设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59869413/

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