我发现表情符号的Unicode名称和在“字符查看器”中显示的苹果名称不同。如何使用Swift获取表情符号的苹果名称?
示例:
表情符号:
Unicode名称(通过.applyingTransform(.toUnicodeName, reverse: false)
获得):
微笑的脸,张开嘴巴和眼睛
苹果名称(从macOS字符查看器中获取):
眯起眼睛的笑脸
我发现表情符号的Unicode名称和在“字符查看器”中显示的苹果名称不同。如何使用Swift获取表情符号的苹果名称?
示例:
表情符号:
Unicode名称(通过.applyingTransform(.toUnicodeName, reverse: false)
获得):
微笑的脸,张开嘴巴和眼睛
苹果名称(从macOS字符查看器中获取):
眯起眼睛的笑脸
SMILING FACE WITH OPEN MOUTH AND SMILING EYES
/System/Library/PrivateFrameworks/CoreEmoji.framework/Versions/A/Resources/en.lproj/AppleName.strings
plutil
将此文件转储,或使用PropertyListDecoder读取它。$ plutil -p AppleName.strings
{
"〰" => "wavy dash"
"‼️" => "red double exclamation mark"
"⁉️" => "red exclamation mark and question mark"
"*️⃣" => "keycap asterisk"
"#️⃣" => "number sign"
"〽️" => "part alternation mark"
"©" => "copyright sign"
...
/* @class CPKDefaultDataSource */
+(void *)localizedCharacterName:(void *)arg2 {
r14 = arg2;
rax = [CPKDefaultDataSource preferredEmojiLocale];
if (rax != 0x0) {
rax = CEMEmojiTokenCreateWithString(r14, rax);
if (rax != 0x0) {
r15 = CEMEmojiTokenCopyName(rax, 0x2);
CFRelease(rax);
if (r15 != 0x0) {
rax = [r15 autorelease];
}
else {
rax = [[CPSearchManager sharedSearchManager] infoForCharcater:r14 infoTag:@"unam"];
}
}
else {
rax = [[CPSearchManager sharedSearchManager] infoForCharcater:r14 infoTag:@"unam"];
}
}
else {
rax = 0x0;
}
return rax;
}
/* @class CPSearchManager */
-(void *)infoForCharcater:(void *)arg2 infoTag:(void *)arg3 {
...
rax = [CPCharacterDatabase sharedDatabase];
rax = [rax createXPCDictionaryForCharacterInfo:r14];
...
rax = [r12 cStringUsingEncoding:0x4];
rax = xpc_dictionary_get_value(r15, rax);
...
rax = xpc_dictionary_create(0x0, 0x0, 0x0);
r12 = rax;
xpc_dictionary_set_string(rax, "command", "search_character_info");
xpc_dictionary_set_string(r12, "string", [r14 cStringUsingEncoding:0x4]);
rdx = *(r15 + 0x10);
*(r15 + 0x10) = rdx + 0x1;
xpc_dictionary_set_uint64(r12, "transactionID", rdx + 0x1);
rax = _CPXPCConnection();
rax = xpc_connection_send_message_with_reply_sync(rax, r12);
rax = xpc_dictionary_get_value(rax, "result");
...
}
/System/Library/PrivateFrameworks/CharacterPicker.framework
。如果你正在为 macOS 构建此应用,可以链接到该库以进行私有分发。