简体   繁体   English

用Java打印字符串编码的有线unicode

[英]print string encoding wired unicode in Java

I am trying to convert \\U0001f618 to the symbol that expresses face (I think it's called emoji ?) My code is 我正在尝试将\\ U0001f618转换为表示面部的符号(我认为这是表情符号?),我的代码是

import org.apache.commons.lang3.StringEscapeUtils;
public class Test{
  public static void main(String args[]){
    try{
     String unicode = "\\U0001f618";
     String Title = unicode;
     System.out.println(new String(unicode.getBytes(),"UTF-8"));                                                               
     String Title = StringEscapeUtils.unescapeJava(unicode);
     System.out.println(Title);
    }catch(Exception E){System.out.println(E);}
   }
}

However I can not do it. 但是我做不到。 This code just prints out plain text "\\U0001f618" 此代码仅打印出纯文本“ \\ U0001f618”

I have a bunch of such codes that I need to convert. 我有一堆需要转换的代码。 Any idea? 任何想法?

The first step would be to ensure that you are using a font that supports that unicode character. 第一步是确保您使用的字体支持该unicode字符。 If its just a standard console output, that would be unlikely. 如果只是标准控制台输出,那将是不可能的。

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

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