devinross / tapkulibrary

tap + haiku = tapku, a well crafted open source iOS framework
http://devinross.com/tapku/documentation
MIT License
3.9k stars 653 forks source link

Issues with unescapeHTML #267

Open laszlotuss opened 10 years ago

laszlotuss commented 10 years ago

Hy there, i have problems using unescapeHTML with a json object.

NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&err];
NSString *returnString = [[NSString alloc] initWithBytes: [data bytes] length:[data length] encoding: NSUTF8StringEncoding];
return [[returnString unescapeHTML] dataUsingEncoding:NSUTF8StringEncoding];

And that returned NSData will send to a simple JSON parser:

[NSJSONSerialization JSONObjectWithData:data options:0  error:&jsonParsingError];

And most of the time it works as i expected. What i expect is to replace all """ and all "'". (actually this "'" have a 0 before 39 in my case, so i have to extend the method for work for that also)

But when it comes to a big json string, it failed to convert one """ and it will rise an NSError at parsing like:

Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn't be completed. (Cocoa error 3840.)" (Badly formed object around character 6177.)