Java Swing - JTextField/JTextArea 无法粘贴补充 unicode 字符

发布于 2024-11-29 03:19:03 字数 269 浏览 2 评论 0原文

我已经对 stackoverflow 和 Google 进行了详尽的搜索,但到目前为止我还找不到其他人有类似的问题。

在示例 Java Swing 测试程序中,我创建了一个普通的 JTextField,以便我可以尝试从网页 (http://isthisthingon.org/unicode/) 将字符粘贴到其中。当我用“㓿”(代码点13567)进行测试时,它能够粘贴该字符。该字符是 CJK 表意文字扩展 A 平面中最后列出的字符。但是,当我移动到下一个相关平面 CJK 表意文字扩展 B 时,尝试复制并粘贴字符“

I have done an exhaustive search of stackoverflow and Google, but I have so far been unable to find others having a similar problem.

In a sample Java Swing test program, I create a plain JTextField so that I can try to paste characters into it from a webpage (http://isthisthingon.org/unicode/). When I test with '㓿' (code point 13567) it is able to paste the character. This character is the last listed character in the CJK Ideograph Extension A plane. However, when I move to the next related plane, CJK Ideograph Extension B, trying to copy and paste the character '????' (code point 131072) fails. It does not render a box or any sort of glyph, it appears as if I had nothing in the system clipboard at all.

I realize that CJK Ideograph Extension B is a set of characters that are considered "supplemental" and need two 16bit blocks instead of one when Java encodes them internally as UTF-16. Further testing proves that I am able to display the supplemental characters if I hard-code the text into a display area.

This was tested using Windows 7 and Java 6.

I understand that as of Java 5, support for the supplemental unicode characters was added, however, I am wondering why (or if) the cut and paste functionality in swing still does not allow me to paste these characters. Is there something additional I need to do to tell Java to handle these characters when using the JTextField or JTextArea classes? Is there a way yet for Java's Swing libraries to be able to paste these characters into a text field yet?

Thank you for your time!

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

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

发布评论

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

评论(1

一个人的夜不怕黑 2024-12-06 03:19:03

我一发布这篇文章,我可能就找到了答案。这是JDK 中长期存在的错误

No sooner did I post this, than I may have found my answer. This has been a long standing bug in the JDK.

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