• 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 vs UTF8String (memory question)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cString vs UTF8String (memory question)


  • Subject: Re: cString vs UTF8String (memory question)
  • From: John Timmer <email@hidden>
  • Date: Fri, 12 Dec 2003 15:45:13 -0500

> In short, my question is, can I basically go through my code and
> replace all calls to -cString or -lossyCString with calls to
> -UTF8String instead? Are there going to be any unforeseen consequences?
> (In my case the only C strings I work with tend to be filesystem paths,
> for which I am already using -fileSystemRepresentation, and arguments
> to command-line tools.)

Just a word of warning on doing this arbitrarily - in downloading some web
page info, using UTF8String would mostly work, but occasionally return nil,
leading to sporadic crashes in my app. I wound up having to use
initWithData: encoding: and use NSISOLatin1StringEncoding in order to make
sure that something was consistently generated.

If it had failed every time, it would have been easy to diagnose, but the
erratic nature caused me headaches, so I thought a warning was in order...

Cheers,

JT
_______________________________________________
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 vs UTF8String (memory question)
      • From: Andreas Mayer <email@hidden>
    • Re: cString vs UTF8String (memory question)
      • From: j o a r <email@hidden>
References: 
 >cString vs UTF8String (memory question) (From: Greg Hurrell <email@hidden>)

  • Prev by Date: Re: NSImage, corrupt images and address faults
  • Next by Date: Re: NSImage, corrupt images and address faults
  • Previous by thread: Re: cString vs UTF8String (memory question)
  • Next by thread: Re: cString vs UTF8String (memory question)
  • Index(es):
    • Date
    • Thread