gpt4 book ai didi

java - Unicode 字符 Java

转载 作者:行者123 更新时间:2023-12-02 03:40:28 25 4
gpt4 key购买 nike

我不能在java中使用unicode字符。我把树 unicode 放进去了,它只是以一个小盒子和一个 4 的形式出现。它在一个小程序中,我把代码放在 public void Paint(Graphics g) 中无论如何,代码如下

    g.drawString("\u1F334",150,150);

最佳答案

来自JLS 3.3 :

A compiler for the Java programming language ("Java compiler") first recognizes Unicode escapes in its input, translating the ASCII characters \u followed by four hexadecimal digits to the UTF-16 code unit (§3.1) for the indicated hexadecimal value, and passing all other characters unchanged. Representing supplementary characters requires two consecutive Unicode escapes.

(强调)

具体来说,您需要 UTF-16 BE(大端)编码。对于棕榈树,序列(如 on the page you linked 所示)是 "\uD83C\uDF34"

关于java - Unicode 字符 Java,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36893544/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com