Re: Converting NSString to char constant (answered)
Re: Converting NSString to char constant (answered)
- Subject: Re: Converting NSString to char constant (answered)
- From: KLW <email@hidden>
- Date: Sat, 3 Jan 2004 01:28:29 -0500
Dear Mr. Cox:
Thank you for your response. Just to reassure you, my program is set
up such that the only possible results will be either 'C', 'N', 'I',
or 'E' -- well within the ASCII range.
But I hadn't thought of the possibility that there would be a
problem, and I thank you for pointing it out. As it is, the solution
actually doesn't work without the char cast. Perhaps I could have
said:
unichar cResult = (unichar)[resultAsNSString characterAtIndex:0];
Anyone know if I can use a unichar in a switch() case construct? I
know, I know, I suppose I could just try it, but I happen to not have
Xcode at this machine.
K
On Jan 02, 2004, at 17:24, KLW wrote:
Answered my own question:
char cResult = (char)[resultasNSString characterAtIndex:0];
Anyone have a better, smaller, faster way?
Don't cast the result of -characterAtIndex: to char unless
you're absolutely sure that it is in the ASCII range, otherwise,
you'll be getting back unpredictable values.
--
Clark S. Cox III
email@hidden
http://homepage.mac.com/clarkcox3/
http://homepage.mac.com/clarkcox3/blog/B1196589870/index.html
Content-Type: application/pkcs7-signature;
name=smime.p7s
Content-Disposition: attachment;
filename=smime.p7s
Attachment converted: .xtatic:smime 8.p7s (????/----) (00036E7E)
--
http://www.brokenhill.net
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/~~~~~~~~~~~~~~~~~~~~~~~~
"The only real ideas are the ideas of the shipwrecked"
--Ortega y Gassett
~~~~~~~~~~~~~~~~~~~/~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.