Can you translate php function quoted_printable_decode() to an NSString-based, objective-C function / category method? -
In it, I have found ways to use preg_replace. Anyone who knows any code that can convert a normal NSString into RFC 2045 section 6.7?
Thanks in advance!
There is no way to decode a quoted printable string on cocoa, but you can easily You can write something like:
@interface NSString (QuotedPrintableStrings) + (NSString *) String GeneratedReasoned String: (Const four *) qpString; @f @ Implementation NSSTING (quoted printable stratus) + (NSSTING *) string videuchat printable string: (Constant *) Kpstern {cons char * p = qpString; Char * ep, * utf8_string = malloc (strlen (qpString) * sizeof (char)); NSParameterAssert (utf8_string); Ep = utf8_string; While (* p) {switch (* p) {case '=': NSAssert1 (* (p + 1)! = 0 & amp; * (p + 2)! = 0, @ "Distorted QP string:% s" , QpString); If (* (P + 1)! = '\ R') {int i, byte [2]; For (i = 0; i & lt; 2; i ++) {byte [i] = * (p + i + 1); If (isdigit (byte [i])) byte [i] - = 0x30; And byte [i] - = 0x37; Nsart (byte [i] & gt; = 0 & amp; amp; byte [i] & lt; 16, @ "bad encoded characters"); } * (AP ++) = (four) (byte [0] <<4) | Byte [1]; } P + = 3; to continue; Default: * (AP ++) = * (P ++); to continue; }} Return [[[NSString alloc] initWithBytesNoCopy: utf8_string Length: strlen (utf8_string) encoding: NSUTF8 string encoding free when yes: yes] autorlage]; } @end
Comments
Post a Comment