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

标签 cocoa macos core-foundation

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

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

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

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

最佳答案

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

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

...

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

关于cocoa - 如何确定 MacOS 上货币符号位于数字的左侧还是右侧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/198526/

相关文章:

macos - 检查鼠标是否在 NSTableView 内单击

cocoa - 如何实现像地址簿 "Show in Large Type"这样的HUD风格的窗口

javascript - OS X 和 iOS Safari history.replaceState 限制抛出 SecurityError : DOM Exception 18

ios - 使用服务器证书签署 iPhone 配置文件

ios - 在 GCD 串行队列上安排和使 NSTimers 失效是否安全?

c++ - 检索当前/自己的包的路径

cocoa - 尝试通过 NSTreeController 和 NSBrowser 使用 NSManagedObjectModel

cocoa - Swift - 选择文件时发出警告(Cocoa)

xcode - NS 对象没有可识别的成员

ios - EXC_BAD_ACCESS 在 iOS 6 上,但在更改 CFDataRef 的字节时不是 5