• 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
problem with NSString, UTF8, pathnames
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

problem with NSString, UTF8, pathnames


  • Subject: problem with NSString, UTF8, pathnames
  • From: "James Stein" <email@hidden>
  • Date: Thu, 25 Oct 2007 10:46:43 -0700

To my surprise:
an NSString returned by Cocoa will cause NSLog to crash.
Details:

I override 'openDocumentWithContentsOfURL:display:error'
in order to see what is happening.
The NSURL (absoluteURL) passed in comes from Cocoa's normal open file dialog.
so:
 NSString *s = [absoluteURL description];  // make NSString from NSURL
 NSLog(s);  // often works, sometimes crashes.

I think the  problem is that the pathname is UTF8-encoded,
but has not been properly decoded when it arrives in string 's'.

On the web I found methods to create NSStrings from c-strings
and from UTF8-encoded strings; but I don't find a way to reverse the process.

Seems like a bug to me, that Coca will create an object
that will create description than will crash when passed to NSLog.
(Maybe it will be gone tomorrow, thanks to Leopard & XCode 3.0)

But whatever, is there a workaround, or must I consider this as harmful?
    NSLog( [validCocoaObject description] );
_______________________________________________

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: problem with NSString, UTF8, pathnames
      • From: "Clark Cox" <email@hidden>
    • Re: problem with NSString, UTF8, pathnames
      • From: Dave Hersey <email@hidden>
    • Re: problem with NSString, UTF8, pathnames
      • From: glenn andreas <email@hidden>
  • Prev by Date: Re: Any caveats to using fork in a Foundation/CoreFoundation tool?
  • Next by Date: Re: Any caveats to using fork in a Foundation/CoreFoundation tool?
  • Previous by thread: Re: Any caveats to using fork in a Foundation/CoreFoundation tool?
  • Next by thread: Re: problem with NSString, UTF8, pathnames
  • Index(es):
    • Date
    • Thread