Converting string to encoding
Converting string to encoding
- Subject: Converting string to encoding
- From: Dex Morgan <email@hidden>
- Date: Sat, 14 Jun 2008 16:43:56 +0200
Hello,
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];
This is an example of the message (it's an UTF-8 + quoted printable
string):
http://pastebin.com/m5b3f114e
This is the code I've used to replace escapes sequences
(stringFromQuotedPrintableFormat)
http://pastebin.com/m763590f7
Anyone can tell me what I'm wrong. I'm going crazy with this thing :)_______________________________________________
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