I have searched a lot about UTF8 decoding, but not found the answer yet.
I receive an UTF-8 decode NSString from my NSXMLParser:
NSString *tempString = @"Test message readability is óké";
In someway I can't find the way to change this encoded text to:
Test message readability is óké
I could tell all the options I tried but I don't think that should be necessary. Could please some help?
Thnx!
You're doing it wrong. What you want is:
Also keep in mind that when you initialize string constants, what actually goes to program memory depends on the encoding of the current file. If it's already UTF-8, then the characters will be doubly-encoded - you'll get characters Ã,³, etc. encoded as UTF8 in the C string.
In other words, using a string constant is probably a wrong move to begin with. Please give more context to the problem.
The
NSXMLParser
will treat the text using the character encoding that the XML specifies. I believe in your case the XML do not specify UTF-8 explicitly.The text seems to be ISO Latin 1. If you can not do anything about the server generating the XML then you can apply this hack:
I have verified that this works by testing this from the GDB prompt:
Standart encoding and decoding like this:
For encoding:
For decoding: