Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Swing - JTextField/JTextArea unable to paste supplemental unicode characters

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!

like image 910
Locriansax Avatar asked Nov 04 '22 16:11

Locriansax


1 Answers

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

like image 132
Locriansax Avatar answered Nov 14 '22 21:11

Locriansax