problem with NSString, UTF8, pathnames
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