• 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: Converting string to encoding
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Converting string to encoding


  • Subject: Re: Converting string to encoding
  • From: Ricky Sharp <email@hidden>
  • Date: Sat, 14 Jun 2008 10:29:26 -0500


On Jun 14, 2008, at 9:43 AM, Dex Morgan wrote:

I need to encode a quoted-printable text and convert it to given encoding according to the headers of a message.
I've used some code but the result is wrong.
For example =C3=A8 should be 'รจ' but the result is two symbols (the sqrt symbol and another).
I've made these steps:


1) Read the data and put it into an NSString with ISOLatin1StringEncoding
2) Replaced all =HEX chars sequences
3) Converted to an NSData using ISOLatin1StringEncoding
4) Read it from NSString using the defined encoding


This is the code:
NSString *plain = [[[NSString alloc] initWithData: self encoding:NSISOLatin1StringEncoding] stringFromQuotedPrintableFormat];
NSData *data = [plain dataUsingEncoding: enc allowLossyConversion: NO];
encoded = [[NSString alloc] initWithData: data encoding:enc];


What you're seeing is a reinterpretation of a UTF-8 byte sequence as Latin-1. Instead of specifying an encoding of Latin-1, you need to use UTF-8 instead.

Or, if the original text can be in any encoding, make sure to use whatever encoding is specified.

___________________________________________________________
Ricky A. Sharp         mailto:email@hidden
Instant Interactive(tm)   http://www.instantinteractive.com

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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: 
 >Converting string to encoding (From: Dex Morgan <email@hidden>)

  • Prev by Date: Re: looking for a crc code
  • Next by Date: Re: Converting string to encoding
  • Previous by thread: Re: Converting string to encoding
  • Next by thread: Re: Converting string to encoding
  • Index(es):
    • Date
    • Thread