I have strange behavior with UTF8 encoding:
For example: when i run on simulator
NSString *uni = @"\U0001d11e";
NSString *uni2 = [[NSString alloc] initWithUTF8String:"\xF0\x9D\x84\x9E"];
NSString *uni3 = @"";
NSLog(@"unicode: %@ and %@ and %@",uni, uni2, uni3);
I’ve got the expected result:
unicode: and and
But when i ran it into a real device, here the output:
unicode: ùÑû and ùÑû and ùÑû
I can’t understand why. It is a compilation workaround, or something that i didn’t understood?
I know that the @”” construct can only take ASCII characters. But why this is working on simulator? Do you have an idea on how i can make it works on real device? Thx
Everything is working fine, the bytes are received correctly. It’s just that the device is decoding them as Mac OS Roman instead of UTF-8. All you need to do is to specify to the device that the input is UTF-8. If you don’t know how to do that, then you should provide more details.