Search code examples
htmliosimagexml-parsingurl-encoding

I need an iOS tool to encode HTML?


I am parsing some XML that will have a link such as the following one in it:

http://sale.images.woot.com/Château_de_Brigue_French_RoséhknStandard.jpg

As you can see this link has accented characters in it. iOS has trouble with this an will not load the image given the link in that form. If I go to Google Chrome and navigate to that image, and copy the link in the address bar, I can see that it has encoded the accented characters as follows:

http://sale.images.woot.com/Ch%C3%A2teau_de_Brigue_French_Ros%C3%A9hknStandard.jpg

However, this doesn't make any sense to me because if I go to W3C's URL Encoding Reference, and swap out the accented characters in the link with the numbers in their ASCII chart, it seems like the link should be

http://sale.images.woot.com/Ch%E2teau_de_Brigue_French_Ros%E9hknStandard.jpg

but this does not work- in my browser or loading into an image view in iOS.

Could someone please explain what's going on? Thanks :)

Also, if someone knows an easy way to encode URLs in iOS that would be great.


Solution

  • EDIT: If you copy and paste the é character from the w3schools website into their URL encoding tool, it will come back as %C3%A9. My previous answer here claimed that they were different characters, but I was wrong. It basically just looks like the table on that page is wrong. In any event, the iOS functions described in this page should give you a good answer to what you need to do for your project.