First of all, I found this: Objective C HTML escape/unescape, but it doesn’t work for me.
My encoded characters (come from a RSS feed, btw) look like this: &
I searched all over the net and found related discussions, but no fix for my particular encoding, I think they are called hexadecimal characters.
Those are called Character Entity References. When they take the form of
&#<number>;they are called numeric entity references. Basically, it’s a string representation of the byte that should be substituted. In the case of&, it represents the character with the value of 38 in the ISO-8859-1 character encoding scheme, which is&.The reason the ampersand has to be encoded in RSS is it’s a reserved special character.
What you need to do is parse the string and replace the entities with a byte matching the value between
&#and;. I don’t know of any great ways to do this in objective C, but this stack overflow question might be of some help.Edit: Since answering this some two years ago there are some great solutions; see @Michael Waterfall’s answer below.