特殊表情符号无法在设备中正确显示

Special Emoji doesn't present correctly in device

我在 UILabel 中使用 unicode("\uE43B"),奇怪的是它在模拟器中工作但在真实设备中不工作。代码如下:

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
[self.view addSubview:label];
label.text = @"The emoji is:\uE43B";
label.textAlignment = NSTextAlignmentCenter;

模拟器中的结果运行秒:

当我在我的设备(iPhone6 9.3.2)中运行它时,它显示一个矩形字符。

我在 Google 中搜索 \uE43B 并且 this site 说:

This is a Private Use codepoint. That is, it is deliberately not assigned to any character. It was added to Unicode in version 1.1 and belongs to the block Private Use Area.

但是我还是不明白模拟器是怎么工作的,微信等一些应用也可以显示表情符号。

您可能在 Mac 上使用了您在 iPhone 上没有使用的自定义字体。正如您所注意到的,这不是一个正确的 Unicode 代码点。这是一个私人使用的角色。如果需要,可以将这些代码点添加到字体中。

iOS 模拟器只是一个 Mac 应用程序,其中包含 Mac 兼容版本的 UIKit。 Mac 上可用的内容将可用于模拟器,即使它们在 iOS 设备上不可用。

您引用的特定字符是 U+1F38F (CARP STREAMER)。 我不知道你为什么把它映射到 U+E43B。有可能您的亚洲字体将其作为遗留代码点(私有字符的常见用法)。