iphoneobjective-cdecodequoted-printable

decoding quoted-printables


I am looking for a way to decode quoted-printables.

The quoted-printables are for arabic characters and look like this:

=D8=B3=D8=B9=D8=A7=D8=AF

I need to convert it to a string, and store it or display..

I've seen post on stackoverflow for the other way around (encoding), but couldn't find decoding.


Solution

  • Uhm, it's a little hacky but you could replace the = characters with a % character and use NSString's stringByReplacingPercentEscapesUsingEncoding: method. Otherwise, you could essentially split the string on the = characters, convert each element to a byte value (easily done using NSScanner), put the byte values into a C array, and use NSString's initWithBytes:length:encoding: method.

    Note that your example isn't technically in quoted-printable format, which specifies that a quoted-printable is a three character sequence consisting of an = character followed by two hex digits.