Re: Unicode-savvy text handling
Subject : Re: Unicode-savvy text handling
From: Laurence Harris <email@hidden >
Date: Thu, 21 Jun 2007 18:53:54 -0400
Delivered-to: email@hidden
Delivered-to: email@hidden
Excellent. That's what I'm doing now. Thanks,
Larry
On Jun 21, 2007, at 6:05 PM, Chris Espinosa wrote:
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
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.