I'm fetching data from an XML source and parsing through it with tbxml. Everything is working fine until I get to a latin letter like the "é" it will display as: Code:
é
I don't see a proper method of NSString to do the conversion. Any ideas?
This seems like a pretty common problem. Check out HTML character decoding in Objective-C / Cocoa Touch
You can use a regex. A regex is a solution to, and cause of, all problems! :)
The example below uses, at least as of this writing, the unreleased RegexKitLite 4.0. You can get the 4.0 development snapshot via svn:
shell% svn co http://regexkit.svn.sourceforge.net/svnroot/regexkit regexkit
The examples below take advantage of the new 4.0 Blocks feature to do a search and replace of the
é
character entities.This first example is the "simpler" of the two. It only handles decimal character entities like
é
and not hexadecimal character entities likeé
. If you can guarantee that you'll never have hexadecimal character entities, this should be fine:Compile and run with: