• 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: Convert between encodings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Convert between encodings


  • Subject: Re: Convert between encodings
  • From: Douglas Davidson <email@hidden>
  • Date: Wed, 6 Dec 2006 10:31:35 -0800


On Dec 6, 2006, at 10:19 AM, malcom wrote:

I've just asked this question some time ago but I've not received any
solution. So now I try again with other words.

Suppose to have some data written to a file (this data was taken using
NSISOLatin1StringEncoding and then saved to file).
Now I need to get it (NSData or NSString) and convert to
NSUTF8StringEncoding (it contains an header that tell me what kind of
encoding is used).
How can I need to proceed?

The best guess I can make is that you are operating from a fundamental misconception here; you seem to think that NSStrings have encodings. NSStrings are abstract representations of strings, and are fundamentally encoding-independent. The data from which one might create an NSString, on the other hand, and the data one might extract from one, must have an encoding. You could use, for example initWithData:encoding: with NSISOLatin1StringEncoding, and then dataUsingEncoding: with NSUTF8StringEncoding.


Douglas Davidson

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


References: 
 >Convert between encodings (From: malcom <email@hidden>)

  • Prev by Date: Re: Passing a SEL into KVC
  • Next by Date: Re: thread spinning ...
  • Previous by thread: Convert between encodings
  • Next by thread: Re: Convert between encodings
  • Index(es):
    • Date
    • Thread