使用NSString编写Unicode字符 [英] Writing a unicode character with NSString

查看:83
本文介绍了使用NSString编写Unicode字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在新项目中使用符号字体Symbolicons代替了图像。但是,似乎无法使用NSString设置超过4个字符的任何代码。

I'm using the symbol font Symbolicons instead of images in a new project. However, it seems that any code over 4 characters can't be set using NSString.

示例:

self.saveDealButton.titleLabel.font = [UIFont fontWithName:@"SS Symbolicons" size:31.0f];
[self.saveDealButton setTitle:@"\u1F4E5" forState:UIControlStateNormal];

但是将不起作用:

self.shareButton.titleLabel.font = [UIFont fontWithName:@"SS Symbolicons" size:31.0f];
[self.shareButton setTitle:@"\uF601" forState:UIControlStateNormal];

工作正常。

推荐答案

对于补充多语言平面中的那些字符,如您的示例所示,在转义字符串中使用大写 U ,后跟八个十六进制代码。因此应将其写为 \U0001F4E5

For those characters in the Supplementary Multilingual Plane, as in your example, use the uppercase U in the escape string and followed by eight hex code. So it should be written as \U0001F4E5.

这篇关于使用NSString编写Unicode字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆