Closed paulrehkugler closed 5 years ago
I've been experiencing this issue since I got a new iPhone with iOS 12. I looked through the code of the app a bit a few months ago, but I wasn't able to find the problem. Unfortunately this lead me to switch to the xkcd: os app, but I don't like it -- I'd love to go back to your app if this issue gets fixed! I'll take a look at the code again tonight and see if I can find anything.
Okay, I actually ran it on the iOS emulator this time instead of just looking at the code. The high-level blame is this line:
Removing that function call (replacing it with NSData *fixedData = data;
for example) fixes the problem and comics can load past 1248. Clearly something about the json for comic 1249 breaks that function's algorithm. I'll keep investigating.
EDIT:
I found the problem, and it's not a technically bug in that function. However, I don't understand the purpose of the function. It appears to be converting single-byte Unicode escape sequences (in the case of comic 1248, its the sequence \u00f6
) and replacing them with their ASCII form. In this case it converts it to the Extended ASCII code 246, ö
. However, JSON is defined to be encoded in UTF-8, and usage of the Extended ASCII codes are incompatible with UTF-8.
The function isn't technically breaking (at least not in this case) -- it successfully converts the escape sequence "\u00f6"
to the single byte 0xF6 -- but it generates invalid UTF-8 which the the JSON parser errors on.
At least as of iOS 12, Apple's JSON library is capable of correctly parsing single-byte Unicode escape sequences. So this function dataByFixingFuckedUpUnicodeInJSON
seems like it should be removed entirely.
Thanks so much for your help! This should be fixed with PR #75.
Some users cannot access comics more recent than 1248. As far as I can tell, https://xkcd.com/1248/info.0.json and https://xkcd.com/1249/info.0.json both have well-formed JSON, so this may be a local issue with the app.