• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Hex to NSString or NSData
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Hex to NSString or NSData
      • From: Michael Ash <email@hidden>
References: 
 >Hex to NSString or NSData (From: "Mr. Gecko" <email@hidden>)
 >Re: Hex to NSString or NSData (From: Jerry Krinock <email@hidden>)
 >Re: Hex to NSString or NSData (From: "Mr. Gecko" <email@hidden>)
 >Re: Hex to NSString or NSData (From: Gwynne Raskind <email@hidden>)
 >Re: Hex to NSString or NSData (From: "Mr. Gecko" <email@hidden>)

  • Prev by Date: Re: NSApplication and command line args
  • Next by Date: Re: Garbage collector related crash
  • Previous by thread: Re: Hex to NSString or NSData
  • Next by thread: Re: Hex to NSString or NSData
  • Index(es):
    • Date
    • Thread