• 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: cString deprecated!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: cString deprecated!
      • From: Peter Sichel <email@hidden>
  • Prev by Date: Re: Storing NSRect in an NSMutableArray...
  • Next by Date: [OT] Re: General doubt... textured or not?
  • Previous by thread: Re: cString deprecated!
  • Next by thread: Re: cString deprecated!
  • Index(es):
    • Date
    • Thread