Re: Hex to NSString or NSData
Re: Hex to NSString or NSData
- Subject: Re: Hex to NSString or NSData
- From: Uli Kusterer <email@hidden>
- Date: Sun, 10 May 2009 10:50:25 +0200
On 10.05.2009, at 05:57, Mr. Gecko wrote:
int char2hex(unichar c) {
switch (c) {
case '0' ... '9': return c - '0';
case 'a' ... 'f': return c - 'a' + 10;
case 'A' ... 'F': return c - 'A' + 10;
default: return -1;
}
}
As long as you are aware that this is not standard C, but actually a
GCC extension that implements a feature dearly missed from Pascal...
Ranges in switches will not compile on any other compiler than GCC.
And before you think that won't affect you, remember that Apple are
working on the clang compiler front-end and the llvm backend, which
might one day become a new compiler completely independent from GCC.
Thank you though -- I wasn't even aware that GCC had this extension
before I tried to compile this code and then started googling.
Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden