2008-10-13 39 views
1

如何使用Mac Carbon項目中的CFLocale/CFNumberFormatter來確定貨幣符號是否應該位於數字的左側或右側?如何確定貨幣符號是在MacOS上的數字左側還是右側

我需要與電子表格應用程序接口,該應用程序需要我傳遞一個數字,貨幣符號,貨幣符號位置和填充,而不是使用CFNumberFormatter創建的CStringRef。

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

向我提供貨幣符號作爲字符串。但我迷失在如何確定貨幣符號的位置...

回答

2

作爲一種解決方法,我已經開始創建一個代表貨幣值的字符串,並通過搜索字符串來確定貨幣符號的位置,但這確實對我來說很腥。

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

...

隨意打我一個捲起的報紙,告訴我真正的答案...

0

你可以嘗試檢查格式字符串從CFNumberFormatterGetFormat返回。它looks like你想要搜索¤這是\u00A4

相關問題