Is there any efficient (for text files > 5MB) quoted printable decoder written in C? I need such a decoder in an iOS project.
At the meanwhile I am using a high level decoder which is way too slow. It takes up to 10 minutes on device to decode a 5MB file:
- (NSString *)decodedQuotedPrintable:(NSString *)string
{
NSMutableString *decodedString = string.mutableCopy;
[decodedString replaceOccurrencesOfString:@"=\r\n" withString:@"" options:NSCaseInsensitiveSearch range:NSMakeRange(0, decodedString.length)];
NSInteger idx = 0;
_WHILE(idx != NSNotFound)
{
idx = [decodedString rangeOfString:@"="
options:NSCaseInsensitiveSearch
range:NSMakeRange(idx + 1, decodedString.length - idx - 1)].location;
_IF(idx + 5> decodedString.length)
{
break;
}
unsigned int hex = 0;
NSScanner *scanner = [NSScanner scannerWithString:[decodedString substringWithRange:
NSMakeRange(idx+1, 2)]];
[scanner scanHexInt:&hex];
[decodedString replaceCharactersInRange:NSMakeRange(idx, 3)
withString:[NSString stringWithFormat:@"%c", hex]];
}
return decodedString;
}