如何确定 MacOS 上货币符号位于数字的左侧还是右侧

发布于 2024-07-06 10:49:38 字数 384 浏览 6 评论 0原文

如何在 Mac Carbon 项目中使用 CFLocale / CFNumberFormatter 确定货币符号应该位于数字的左侧还是右侧?

我需要与电子表格应用程序交互,该应用程序要求我传递数字、货币符号、货币符号位置和填充,而不是使用 CFNumberFormatter 创建的 CStringRef。

CFLocaleRef currentLocale = CFLocaleCopyCurrent();
CFTypeRef currencySymbol = CFLocaleGetValue (currentLocale, kCFLocaleCurrencySymbol);

为我提供字符串形式的货币符号。 但我不知道如何确定货币符号的位置......

How do I determine if the currency symbol is supposed to be on the left or right of a number using CFLocale / CFNumberFormatter in a Mac Carbon project?

I need to interface with a spreadsheet application which requires me to pass a number, currency symbol, currency symbol location and padding instead of a CStringRef created with CFNumberFormatter.

CFLocaleRef currentLocale = CFLocaleCopyCurrent();
CFTypeRef currencySymbol = CFLocaleGetValue (currentLocale, kCFLocaleCurrencySymbol);

provides me with the currency symbol as a string. But I'm lost on how to determine the position of the currency symbol...

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

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

发布评论

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

评论(2

平生欢 2024-07-13 10:49:38

作为解决方法,我已开始创建一个表示货币值的字符串,并通过搜索该字符串来确定货币符号的位置,但这对我来说确实看起来很可疑。

    CFNumberFormatterRef numberFormatter = CFNumberFormatterCreate(kCFAllocatorDefault, CFLocaleCopyCurrent(), kCFNumberFormatterCurrencyStyle);
    double someNumber = 0;
    CFStringRef asString = CFNumberFormatterCreateStringWithValue(kCFAllocatorDefault, numberFormatter, kCFNumberDoubleType, &someNumber);

...

随意用卷起的报纸打我,告诉我真正的答案...

As a workaround, I have started to create a string representing a currency value and determining the position of the currency symbol by searching the string, but this sure looks fishy to me.

    CFNumberFormatterRef numberFormatter = CFNumberFormatterCreate(kCFAllocatorDefault, CFLocaleCopyCurrent(), kCFNumberFormatterCurrencyStyle);
    double someNumber = 0;
    CFStringRef asString = CFNumberFormatterCreateStringWithValue(kCFAllocatorDefault, numberFormatter, kCFNumberDoubleType, &someNumber);

...

Feel free to hit me with a rolled-up newspaper and tell me the real answer...

我们只是彼此的过ke 2024-07-13 10:49:38

您可以尝试检查从 CFNumberFormatterGetFormat 返回的格式字符串。 看起来您想要搜索¤ 即 \u00A4

You could try inspecting the format string returned from CFNumberFormatterGetFormat. It looks like you want to search for ¤ which is \u00A4.

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