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

Convert between encodings


  • Subject: Convert between encodings
  • From: malcom <email@hidden>
  • Date: Wed, 6 Dec 2006 19:19:20 +0100

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?

Case 1:
NSData *data = [self getDataInRange: _rg];
NSString *str = [[NSString alloc] initWithData: data encoding:
NSUTF8StringEncoding];

don't recognize the utf8chars.

Case 2:
NSData *data = [self getDataInRange: _rg];
NSString *str = [[NSString alloc] initWithData: data encoding:
NSISOLatin1StringEncoding];
NSString *utf8string = [[NSString alloc] initWithUTF8String: [str
cString]/[str utf8String]...]

same thing...
What's the way to convert an NSString (that basically works with unicode)
from one encoding to another?
Thank you very much.
_______________________________________________

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


  • Follow-Ups:
    • Re: Convert between encodings
      • From: Alastair Houghton <email@hidden>
    • Re: Convert between encodings
      • From: Douglas Davidson <email@hidden>
  • Prev by Date: Dynamically check for method
  • Next by Date: Re: Passing a SEL into KVC
  • Previous by thread: Re: Dynamically check for method
  • Next by thread: Re: Convert between encodings
  • Index(es):
    • Date
    • Thread