Re: foundation kit (help i'm new to cocoa)
Re: foundation kit (help i'm new to cocoa)
- Subject: Re: foundation kit (help i'm new to cocoa)
- From: Mike Ferris <email@hidden>
- Date: Mon, 6 Jan 2003 09:01:13 -0800
-UTF8String is good if UTF8 is the encoding you want.
-cString is bad because it uses the "default" encoding which can be
different for different users and therefore you wind up in a situation
where it will fail for some users with the same string that worked for
other users.
-lossyCString will convert to the default encoding and will not choke
if the conversion cannot be done because of some of the characters in
the string (you'll get a substitute character ('?' I think) for any
unicodes that cannot be converted to the default encoding.
If your string contains only ASCII characters (ie Unicodes from
0x0001-0x007F) then any of these methods will give the same answer.
In general, some thought is required when your app needs to convert
NSStrings to (char *) data. If you can avoid it, don't do it. If you
have to, think about the encoding issues (preferrably as a global
design point of your app... think about how your app as a whole needs
to deal with textual data and be consistent throughout). And, my own
opinion is that if you can use UTF-8 as the encoding when dealing with
textual data, you should. It is usually a better choice for a number
of reasons. But if you're dealing with another subsystem that expects
a specific encoding, you may not have that choice.
Mike
_______________________________________________
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.