简体   繁体   中英

How to handle unicode chars in Java

I have been trying to achieve the following :

I want to be able to paste a string of Unicode characters ex : 🖕🏼🙅🏽 without java showing them as being unrecognized. How do I make a Java JTextPane able to handle Unicode characters?

If you want to use Unicode character you have to write it like this: \\u[unicode] . So for example:

 JOptionPane.showMessageDialog(null, "\u2764Guess number", "game", JOptionPane.INFORMATION_MESSAGE);

would produce the folowing: ❤Guess number. I hope i answered your question.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM