| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
On Jun 21, 2007, at 2:18 PM, Laurence Harris wrote: So what's the most modern, recommended, Unicode-savvy way to convert a text string into a numeric value? CFNumberFormatter? #include <CoreFoundation/CoreFoundation.h> int main (int argc, const char * argv[]) { CFStringRef myNumericString; CFNumberFormatterRef formatter; SInt32 v; unsigned char utf8Array[12] = {0xEF, 0xBC, 0x91, 0xEF, 0xBC, 0x92, 0xEF, 0xBC, 0x93, 0xEF, 0xBC, 0x94}; myNumericString = CFStringCreateWithBytes(NULL, utf8Array, 12, kCFStringEncodingUTF8, false); formatter = CFNumberFormatterCreate(NULL, CFLocaleCopyCurrent(), kCFNumberFormatterDecimalStyle); if (CFNumberFormatterGetValueFromString(formatter, myNumericString, NULL, kCFNumberSInt32Type, (SInt32*)&v)) { printf("The numeric value is %d\n", v); return 0; } else { printf("Error getting value from string.\n"); return 2; } } Chris
|
_______________________________________________ Do not post admin requests to the list. They will be ignored. Carbon-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/carbon-dev/email@hidden This email sent to email@hidden
| References: | |
| >Unicode-savvy text handling (From: Rick Mann <email@hidden>) | |
| >Re: Unicode-savvy text handling (From: Laurence Harris <email@hidden>) | |
| >Re: Unicode-savvy text handling (From: Rick Mann <email@hidden>) | |
| >Re: Unicode-savvy text handling (From: Laurence Harris <email@hidden>) | |
| >Re: Unicode-savvy text handling (From: Deborah Goldsmith <email@hidden>) | |
| >Re: Unicode-savvy text handling (From: Laurence Harris <email@hidden>) | |
| >Re: Unicode-savvy text handling (From: Deborah Goldsmith <email@hidden>) | |
| >Re: Unicode-savvy text handling (From: Laurence Harris <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.