问题
I have something like :
"Jossmaisel ♡"
I want to show it in UILabel.But the special character shows up as two chars instead of the heart sign.
Is it something related to the encoding? Somehow I need to do something about UTF 8 ?
Can anyone kindly help me out ?
回答1:
Have you escaped the heart character? As in @"Jossmaisel \u2661"
? In UTF-8 encoding, it would take three bytes.
回答2:
Ok, so figured it out :
From Here
NSString *encoded_string = @"ü";
const char *ch = [encoded_string cStringUsingEncoding:NSISOLatin1StringEncoding];
NSString *decode_string = [[NSString alloc]initWithCString:ch encoding:NSUTF8StringEncoding];
NSLog(@"%@",decode_String);
来源:https://stackoverflow.com/questions/12658743/regarding-special-characters-in-uilabel-probably-something-to-do-with-encoding