Re: cString deprecated!
Re: cString deprecated!
- Subject: Re: cString deprecated!
- From: Matt Neuburg <email@hidden>
- Date: Tue, 3 Sep 2002 17:26:16 -0700
On Tue, 03 Sep 2002 13:01:33 -0700, Kris Amico <email@hidden> said:
>
Forgive my ignorance, but I am wondering how the technique you describe
>
below is different from using NSString's lossyCString instance method?
>
>
On 9/3/02 9:20 AM, "Matt Neuburg" <email@hidden> wrote:
>
>
>
>
> - (const char*) myCString: (int) encoding {
>
> return [[[self stringByAppendingString:
>
> @"\0"] dataUsingEncoding: encoding
>
> allowLossyConversion:YES]
>
> bytes];
>
> }
You seem to have missed the point of what this thread is about.
The technique supplied here differs crucially from lossyCString in that it
lets you specify an encoding. lossyCString does not, and is therefore yet
another in the "axis of evil" C string methods that should be deprecated
(thank you for pointing this out).
The problem that this thread is about is that cString, lossyCString, and
stringWithCString all use the "default C-string encoding", which will
differ on different systems and over which you (the programmer) have no
control whatever. Therefore you shouldn't use those calls at all. m.
--
matt neuburg, phd = email@hidden,
http://www.tidbits.com/matt
pantes anthropoi tou eidenai oregontai phusei
Subscribe to TidBITS! It's free and smart.
http://www.tidbits.com/
_______________________________________________
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.