Eclipse调试器错误地显示了CJK角色-Java
我正在处理错误显示错误显示的错误。
我正在使用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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
字符“
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.
看起来这是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
Detail Formatter Output
Screenshots
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.