Re: stringWithCString vs stringWithUTF8String
Re: stringWithCString vs stringWithUTF8String
- Subject: Re: stringWithCString vs stringWithUTF8String
- From: Chris Ridd <email@hidden>
- Date: Mon, 04 Nov 2002 18:26:29 +0000
On 4/11/02 6:09 pm, Brian Redman <email@hidden> wrote:
>
I've got some email text I read from a pop server. According to the
>
header it's:
>
>
Content-Type: text/plain; charset=ISO-8859-1
>
Content-Transfer-Encoding: 8bit
>
>
When I create an NSString from the char* text using
>
stringWithUTF8String I get nil. If I use stringWithCString it works.
>
I get an NSString containing my text.
>
If I want to avoid stringWithCstring what method(s) should I be using
>
to create the NSString from this text? I read through the NSString
>
encoding material but I really don't get it.
Since +stringWithCString is locale-dependent, so your app would have failed
somewhere where the default encoding was different from yours.
Use NSString's -initWith
Data:encoding: method, where the encoding is a
constant like NSISOLatin1StringEncoding. The NSString documentation
describes that method and mentions some other encoding constants you might
be interested in too.
Cheers,
Chris
_______________________________________________
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.