Il n'y a pas méthode sur Cocoa pour décoder une chaîne imprimable cité, mais vous pouvez facilement écrire quelque chose vous, comme:
@interface NSString (QuotedPrintableStrings)
+(NSString*)stringWithQuotedPrintableString:(const char *)qpString;
@end
@implementation NSString (QuotedPrintableStrings)
+(NSString*)stringWithQuotedPrintableString:(const char *)qpString
{
const 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 && *(p + 2) != 0, @"Malformed QP String: %s", qpString);
if(*(p + 1) != '\r') {
int i, byte[2];
for(i = 0; i < 2; i++) {
byte[i] = *(p + i + 1);
if(isdigit(byte[i]))
byte[i] -= 0x30;
else
byte[i] -= 0x37;
NSAssert(byte[i] >= 0 && byte[i] < 16, @"bad encoded character");
}
*(ep++) = (char) (byte[0] << 4) | byte[1];
}
p += 3;
continue;
default:
*(ep++) = *(p++);
continue;
}
}
return [[[NSString alloc] initWithBytesNoCopy:utf8_string length:strlen(utf8_string) encoding:NSUTF8StringEncoding freeWhenDone:YES] autorelease];
}
@end