本文介绍了Android表情符号问题(将“ \uD83D\uDE04”转换为0x1F604)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以通过这种方式在textview中显示表情符号
解决方案
执行类似的操作。
将UTF-16转换为UTF-8
字符串文本=新字符串( uD83D\uDE04 .getBytes(),StandardCharsets.UTF_8);
获取代码点
int代码点= text.codePointAt(0);
将其转换为Unicode
String yourUnicode = U + + Integer.toHexString(codepoint)
I can display emoji in textview by this way how set emoji by unicode in android textview , but how to convert something like "uD83D\uDE04" to the code point 0x1F604("uD83D\uDE04" represent 0x1F604)?
解决方案
Do something like this.
Convert UTF-16 to UTF-8
String text = new String("uD83D\uDE04".getBytes(), StandardCharsets.UTF_8);
Get the code point
int codepoint = text.codePointAt(0);
Convert it to Unicode
String yourUnicode="U+"+Integer.toHexString(codepoint)
这篇关于Android表情符号问题(将“ \uD83D\uDE04”转换为0x1F604)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!