Regarding special characters in UILabel (probably something to do with encoding ? UTF8?)

对着背影说爱祢 提交于 2019-12-12 00:28:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!