Java Swing - JTextField/JTextArea 无法粘贴补充 unicode 字符
我已经对 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我一发布这篇文章,我可能就找到了答案。这是JDK 中长期存在的错误。
No sooner did I post this, than I may have found my answer. This has been a long standing bug in the JDK.