在 android 文本视图中将 \u00F0\u009F\u0098\u0098 字符串显示为表情符号?
Display \u00F0\u009F\u0098\u0098 string to emoji in android textview?
str = videoname.get(i);
String toServer = str;
String toServerUnicodeEncoded = StringEscapeUtils.escapeJava(toServer);
viewHolder.textss.setText(toServerUnicodeEncoded);
Log.e("emos",toServerUnicodeEncoded);
我正在使用 volley 从 URL 中检索一个字符串,该字符串中包含我想在 Android TextView 中显示的表情符号。因此,为此,我获取了字符串,然后将其传递到 StringEscapeUtils.escapeJava(toServer)
中,然后我得到了 "\u00F0\u009F\u0098\u0098"
形式的表情符号,而不是 "\uD83D\uDE18
" 形式。那么如何显示表情符号文本视图?
您需要 unescape
您的转义字符串。
您可以使用 StringEscapeUtils.unescapeJava(String) 对其进行反转义。
问题已完全解释here。
您不需要将其转换为 unicode 直接使用该字符串代码
TextView txt = (TextView) findViewById(R.id.txt);
txt.setText("\u00F0");
有关更多 unicide 代码,请查看此 URL
希望对您有所帮助。
TextView txt_price = (TextView) findViewById(R.id.txt_price);
txt_price.setText("\u20B9" + "5000");
这是html编码字符串。校验码:
String txt = "\u00F0\u009F\u0098\u0098";
tvHihiView.setText(Html.fromHtml(txt));
String title = new String(c.getString("title").getBytes("ISO-8859-1"), "UTF-8");
在解析响应时我现在使用这个代替:
String title = String(c.getString("title");
这解决了我的表情符号问题。
这对我有用,试试这个。
导入这个库
implementation 'org.apache.commons:commons-lang3:3.4'
然后用它的方法把String(emoji code)转成Emoji
显示在TextView
textView.setText(StringEscapeUtils.unescapeJava(string_value));
Eg:-
输入字符串 :-
"\ud83d\ude01"
结果:-
str = videoname.get(i);
String toServer = str;
String toServerUnicodeEncoded = StringEscapeUtils.escapeJava(toServer);
viewHolder.textss.setText(toServerUnicodeEncoded);
Log.e("emos",toServerUnicodeEncoded);
我正在使用 volley 从 URL 中检索一个字符串,该字符串中包含我想在 Android TextView 中显示的表情符号。因此,为此,我获取了字符串,然后将其传递到 StringEscapeUtils.escapeJava(toServer)
中,然后我得到了 "\u00F0\u009F\u0098\u0098"
形式的表情符号,而不是 "\uD83D\uDE18
" 形式。那么如何显示表情符号文本视图?
您需要 unescape
您的转义字符串。
您可以使用 StringEscapeUtils.unescapeJava(String) 对其进行反转义。
问题已完全解释here。
您不需要将其转换为 unicode 直接使用该字符串代码
TextView txt = (TextView) findViewById(R.id.txt);
txt.setText("\u00F0");
有关更多 unicide 代码,请查看此 URL
希望对您有所帮助。
TextView txt_price = (TextView) findViewById(R.id.txt_price);
txt_price.setText("\u20B9" + "5000");
这是html编码字符串。校验码:
String txt = "\u00F0\u009F\u0098\u0098";
tvHihiView.setText(Html.fromHtml(txt));
String title = new String(c.getString("title").getBytes("ISO-8859-1"), "UTF-8");
在解析响应时我现在使用这个代替:
String title = String(c.getString("title");
这解决了我的表情符号问题。
这对我有用,试试这个。
导入这个库
implementation 'org.apache.commons:commons-lang3:3.4'
然后用它的方法把String(emoji code)转成Emoji
显示在TextView
textView.setText(StringEscapeUtils.unescapeJava(string_value));
Eg:-
输入字符串 :- "\ud83d\ude01"
结果:-