• 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
Re: stringWithCString vs stringWithUTF8String
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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 -initWithData: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.

References: 
 >stringWithCString vs stringWithUTF8String (From: Brian Redman <email@hidden>)

  • Prev by Date: stringWithCString vs stringWithUTF8String
  • Next by Date: Re: metallized interface (offtopic rant)
  • Previous by thread: stringWithCString vs stringWithUTF8String
  • Next by thread: Re: stringWithCString vs stringWithUTF8String
  • Index(es):
    • Date
    • Thread