I'm in the making of an app that talks to a nodejs-server using sockets and JSON, and since iOS 5 has it's own NSJSONSerialization I thought that's may be the road to follow. Before, I used the lightweight yail library.
Anyway, after the migration to NSJSONSerialization I started to encounter problem with the encoding, before the change, the character Ö
would send nicely to the server and back, still being Ö
, but now, NSJSONSerialization leaves Ö
still in unicode char i.e. \U00f6
.
Reading the documentation says that JSON objects is converted to UTF8 by default. And when I convert the response from the server to a simple NSString, the Ö
shows up just as expected, but it's still in JSON of course.
Please help me with your thoughts and so, should I return to yail or use the built-in NSJSONSerialization?
Thank you, Simon
NSLog calls description on its arguments, which happen to print the Unicode code instead of the character itself. Try for example:
NSLog(@"%@", [NSDictionary dictionaryWithObject:@"ö" forKey:@"hello"]);
And you will see that it prints
{
hello = "\U00f6";
}
So, chances are, that your JSON decoding has been done fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With