如何检测 iOS 区域设置中数字在整体和数字之间使用逗号而不是句点的位置小数部分?

发布于 2024-12-25 18:24:12 字数 60 浏览 3 评论 0原文

我有一个特殊要求,即了解当前区域设置是使用基于逗号的数字还是基于句点的数字。有没有简单的方法可以学习这个?

I have a special requirement to learn whether the current locale uses comma-based or period-based numbers. Is there a simple way to learn this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

情绪操控生活 2025-01-01 18:24:14
- (NSString *) getDecimalSeparator
{
return [[NSLocale currentLocale] objectForKey:NSLocaleDecimalSeparator];
}

将返回当前分隔符。我用它来生成有效的 CSV 文件。

- (NSString *) getDecimalSeparator
{
return [[NSLocale currentLocale] objectForKey:NSLocaleDecimalSeparator];
}

Will return current separator. I use it for generating valid CSV files.

深居我梦 2025-01-01 18:24:14

我建议看一下 NSNumberFormatter 类:

NSNumberFormatter 类参考

通过 CoreFoundation 执行此操作的编程指南:

数据格式化编程指南

很高兴您花时间在这上面,在我的应用程序中我使用了自己的时间戳格式,而系统允许您选择你自己的时间戳格式......不用说我有一些愤怒的用户。

I suggest taking a look at the NSNumberFormatter class:

NSNumberFormatter class reference

Programming guide on doing this through CoreFoundation:

Data formatting programming guide

Its good that you are spending time on this, in my application I made use of my own timestamp format, while the system allows you to pick your own timestamp format... needless to say I had some angry users.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文