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?
如何在Mac Carbon项目中使用CFLocale / CFNumberFormatter确定货币符号是否应该位于数字的左侧或右侧?
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.
我需要与电子表格应用程序连接,这需要我传递数字,货币符号,货币符号位置和填充,而不是使用CFNumberFormatter创建的CStringRef。
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...
为我提供货币符号作为字符串。但我迷失在如何确定货币符号的位置......
2 个解决方案
#1
2
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...
随意用报纸打我,告诉我真正的答案......
#2
0
You could try inspecting the format string returned from CFNumberFormatterGetFormat
. It looks like you want to search for ¤
which is \u00A4
.
您可以尝试检查从CFNumberFormatterGetFormat返回的格式字符串。看起来你想要搜索¤这是\ u00A4。
#1
2
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...
随意用报纸打我,告诉我真正的答案......
#2
0
You could try inspecting the format string returned from CFNumberFormatterGetFormat
. It looks like you want to search for ¤
which is \u00A4
.
您可以尝试检查从CFNumberFormatterGetFormat返回的格式字符串。看起来你想要搜索¤这是\ u00A4。