简体   繁体   English

打印Unicode字符Android TextView

[英]Print Unicode Character Android TextView

I am trying to use emoji icons listed here 我正在尝试使用此处列出的表情符号图标

http://apps.timwhitlock.info/emoji/tables/unicode#block-6a-missing-emoticons http://apps.timwhitlock.info/emoji/tables/unicode#block-6a-missing-emoticons

Each icon has a unicode character with it like 每个图标都有一个unicode字符

U+1F601 is the Unicode of "GRINNING FACE WITH SMILING EYES" = 😁 U + 1F601是“用微笑眼睛磨牙”的Unicode =😁

My question here is how can i set this unicode character in textview. 我的问题是如何在textview中设置这个unicode字符。

I cannot create a char from this value as it will require only four hexadecimal values. 我不能从这个值创建一个char,因为它只需要四个十六进制值。

For example i created a char like this 例如,我创建了一个像这样的字符

char c = '\u27A1';

This c works great if i append that to textview and shows me the image properly. 如果我将它附加到textview并正确地向我显示图像,这个c效果很好。 How can i create a char of Unicode value U+1F601 - Bytes UTF-8 \\xF0\\x9F\\x98\\x81 如何创建Unicode值为U + 1F601的字符 - 字节UTF-8 \\ xF0 \\ x9F \\ x98 \\ x81

Also there are certain unicode characters with double values like this U+1F1F7 U+1F1FA = Bytes UTF-8 \\xF0\\x9F\\x87\\xB7\\xF0\\x9F\\x87\\xBA 还有某些具有双值的unicode字符,例如U + 1F1F7 U + 1F1FA =字节UTF-8 \\ xF0 \\ x9F \\ x87 \\ xB7 \\ xF0 \\ x9F \\ x87 \\ xBA

How can i display them all in textview ? 如何在textview中显示它们?

UTF-8 \\xF0\\x9F\\x87\\xB7\\xF0\\x9F\\x87\\xBA it is a UTF8 Format you have to make it in UTF16 format for these charectr. UTF-8 \\ xF0 \\ x9F \\ x87 \\ xB7 \\ xF0 \\ x9F \\ x87 \\ xBA它是UTF8格式,您必须以UTF16格式为这些charectr。

Simply print the UTF16 format String c="\?\?"; 只需打印UTF16格式字符串c =“\\ uD83D \\ uDE01”;

now show the c string in text view. 现在在文本视图中显示c字符串。

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

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