简体   繁体   English

如何将旧的表情符号编码转换为iOS5中的最新编码?

[英]how to convert the old emoji encoding to the latest encoding in iOS5?

sadly, after iOS5 finally released, I got report from my users that they can not login. 遗憾的是,在iOS5终于发布之后,我收到了用户的报告,说他们无法登录。

Because there is emoji symbol in there names, and apple changed the encoding of emoji. 因为名字中有表情符号,苹果改变了表情符号的编码。

so there username contains a old version of emoji, how could I convert them to the new encoding? 所以用户名包含旧版的表情符号,我怎么能将它们转换为新的编码?

thanks! 谢谢!

be specific: one emoji symbol "tiger", it is "\\U0001f42f" in iOS5, but "\" in earlier iOS version. 具体来说:一个表情符号“老虎”,在iOS5中是“\\ U0001f42f”,在早期的iOS版本中是“\\ ue050”。

I had the same problem, after digging for hours and finally found this answer that works for me 我有同样的问题,经过几个小时的挖掘,终于找到了适合我的答案

If you are using rails as your server, this is all you need to do. 如果您使用rails作为服务器,则只需执行此操作即可。 No need to do anything in ios/xcode, just pass the NSString without doing any UTF8/16 encoding stuff to the server. 无需在ios / xcode中执行任何操作,只需传递NSString,而无需对服务器执行任何UTF8 / 16编码。

Postegre stores the code correctly, it's just when you send the json response back to your ios client, assuming you do render json:@message, the json encoding has problem. Postegre正确存储代码,就在你将json响应发送回ios客户端时,假设你渲染json:@message,json编码有问题。

you could test whether you are having json encoding problem in your rails console by doing as simple test in your console test = {"smiley"=>"u{1f604}"} test.to_json 您可以通过在控制台中进行简单测试来测试您的rails控制台中是否存在json编码问题test = {“smiley”=>“u {1f604}”} test.to_json

if it prints out "{\\"smiley\\":\\"\\\"}" (notice the 1 is lost), then you have this problem. 如果它打印出“{\\”smiley \\“:\\”\\ uf604 \\“}”(注意1丢失),那么你有这个问题。 and the patch from the link will fix it. 并且链接中的补丁将修复它。

iOS 5 and OS X 10.7 (Lion) use the Unicode 6.0 standard 'unified' code points for emoji. iOS 5和OS X 10.7(Lion)使用Unicode 6.0标准的“统一”代码点作为表情符号。

iOS 4 on SoftBank iPhones used a set of unofficial code points in the Unicode Private Use Area, and so aren't compatible with any other systems. SoftBank iPhone上的iOS 4在Unicode专用区域中使用了一组非官方代码点,因此与任何其他系统都不兼容。 To convert from this format to proper Unicode 6.0 characters, you'll need to run a big lookup table from Softbank code to Unified over all your current data and all new form data as it gets submitted. 要将此格式转换为正确的Unicode 6.0字符,您需要在软件代码中运行一个大的查找表,以便在提交时对所有当前数据和所有新表单数据进行统一。 You might also want to do Unicode normalisation at this point, so that eg. 此时您可能还想进行Unicode规范化,例如。 fullwidth letters match normal ASCII letters. 全角字母匹配普通的ASCII字母。

See for example this table from a library that does emoji conversion tasks for PHP. 例如,从为PHP执行表情符号转换任务的库中查看此表

Emoji in usernames though? 用户名中的表情符号虽然? 在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM