Eclipse调试器错误地显示了CJK角色-Java

发布于 2025-01-28 04:04:01 字数 98 浏览 4 评论 0原文

我正在处理错误显示错误显示的错误。
我正在使用Eclipse中的一个简单程序进行测试,在调试调试器的“变量”部分时,我错误地显示了一个CJK字符。请参阅下面的屏幕截图。
我刚刚为变量分配了“

I am working on a bug where a CJK character is displayed wrongly.
I am testing using a simple programme in Eclipse and while debugging 'Variables' section of debugger displays one CJK character wrongly. See the screenshot below.
I just assigned "????野家xyz" value to a variable and eclipse debugger is displaying it wrongly. Character '????', which is a surrogate pair, is replaced with a square. But when I printed it using sysout, it is displayed correctly. Default charset used is 'UTF-8' as you can see from the first line printed in the console. Can someone help me to understand why eclipse is showing it wrongly ?

Eclipse showing CJK character wrongly:
Eclipse showing CJK character wrongly

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爱你是孤单的心事 2025-02-04 04:04:01

字符“

The character "????" is what Unicode calls a supplementary character with codepoint U+20BB7 and its UTF-8 encoding is F0 A0 AE B7.

Support for such characters has only been added to Java in Version 1.5 by JSR 204, but the code in Eclipse's jdt.debug that reads Strings in UTF-8 format is older than that.

If you look at the implementation of org.eclipse.jdi.internal.jdwp.JdwpString.read(DataInputStream), you can see that is was never updated to handle supplementary characters (which have four byte sequences starting with 0xF*).

It just checks that the upper nibble of the first byte is >= 14 (0xE), effectively interpreting the character's UTF-8 sequence as E0 A0 AE B7 which corresponds to the sequence U+082E U+00B7. U+082E is not a valid unicode character which is why the rectangle is drawn for it.

If you want to report this issue, the bug tracker for this Eclipse component is here.

み零 2025-02-04 04:04:01

看起来这是Eclipse IDE,变量窗口中的错误。

我添加了一个细节格式化器,以获取文本“

Looks like this is a bug in Eclipse IDE, Variables window.

I have added a detail formatter to get the unicode entities for the text "????野家xyz". Then decoded the returned unicode entities to unicode text using an online tool. Here's the outputs I got.

Detail Formatter Code

String unicodeStr = "";
for (int i = 0; i < this.length(); i++)
    unicodeStr +=  "\\u" + Integer.toHexString(this.charAt(i) | 0x10000).substring(1);
return unicodeStr;

Detail Formatter Output

\ud842\udfb7\u91ce\u5bb6\u0078\u0079\u007a

Screenshots

Detail Formatter Output
Unicode Converter Output

I used this online unicode converter to check the result.

Looks like the data in the variable still corresponds to the correct text, but the IDE can't render it. So I think this should be a bug in Eclipse.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文