status of cString (was const char* to char*)
status of cString (was const char* to char*)
- Subject: status of cString (was const char* to char*)
- From: "Louis C. Sacha" <email@hidden>
- Date: Thu, 27 Nov 2003 16:53:04 -0800
Hello...
But depending on what you're using the result for, UTF8String can
corrupt the string since it translates some valid cString characters
into the UTF8 version of escaped sequences. If you are accessing the
resulting char* byte by byte and working directly on it, it might be
better to use the lossyCString method, which as far as I know will
continue to be supported (although sometimes it seems like I always
end up looking at documentation that was installed by the developer
tools and hasn't been updated properly).
The issue with cString is that it raises an exception if the
conversion to the cString fails, where lossyCString will fail
silently and provide an inexact but usable result.
I have a lot of code that uses cString, that I haven't gotten around
to updating yet. I haven't seen any documentation that specifically
says what is lost in a lossy cString, but I'm assuming that the only
difference occurs when the NSString contains multibyte characters
that are allowed in unicode. So for most uses where you really do
want a cString, lossyCString should work just fine.
Hopefully someone who is up to date on the whole cString/NSString
issue will correct me if I'm wrong about lossyCString...
Louis
As I've mentioned before on this list, the use of cString is
discouraged. You should use UTF8String instead.
See
<http://developer.apple.com/documentation/Cocoa/Reference/Foundation/
ObjC_classic/Classes/NSString.html#//apple_ref/doc/uid/20000154/
cString> for more info.
-Prachi
_______________________________________________
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.
_______________________________________________
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.