【问题标题】:How can i print Java emoji on eclipse [duplicate]我如何在 Eclipse 上打印 Java 表情符号 [重复]
【发布时间】:2021-04-01 15:20:55
【问题描述】:
i tried to use Answers which already were on stackOverflow but couldn't figure it out

这是我的代码, 如何在 Eclipse 控制台上打印表情符号 公共类 SipirtAnimal {

    public static void main(String[] args) {
        // TODO Auto-generated method stub

          Scanner kb = new Scanner(System.in);
          String name = kb.next().toLowerCase();
           System.out.println("================================================");
           System.out.println("YOUR SPIRIT ANIMALS ACCORDING TO YOUR NAME ARE ");
           for(int i=0; i<name.length(); i++) {
               switch(name.charAt(i)) {
               case 'a':{
                   String grinningFace = "\xF0\x9F\x98\x81";
                  System.out.print(b);
               }
           }
        
        
    }
    }
}

【问题讨论】:

    标签: java emoji


    【解决方案1】:

    tl;博士

    String s = "?";  // Paste the emoji character into source code.
    

    粘贴表情符号

    将表情符号粘贴到您的源代码中。

    UTF-8

    我建议您将项目和IDE 设置为在Java 源文件中使用UTF-8 编码。这可以处理由 Unicode 13 定义的所有 143,859 个字符,包括 all the emoji

    如果使用Apache Maven,设置属性&lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;;或Gradle 或 Ivy 中的类似内容。

    String s = "?";
    System.out.println( s ) ;
    

    看到这个code run live at IdeOne.com

    ?

    Character.toString( codePoint )

    或者,将该字符的code point 的十进制数传递给Character.toString

    String y = Character.toString( 128_512 );
    System.out.println( y ) ;
    

    ?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-11-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-18
      • 1970-01-01
      • 1970-01-01
      • 2012-08-14
      相关资源
      最近更新 更多