Short of copying the character to the clipboard and pasting it inside my string, is there a way to draw a greek letter (or for that matter, any unicode character)? I know the code for the character I am trying to draw is U+03F4 according to here. I have tried the following:
g.drawString("U+03F4", 100, 100); // works as a string literal as it should
g.drawString("\U+03F4", 100, 100); // error: Illegal escape character
g.drawString("\\U+03F4", 100, 100); // thought I could trick it. Just draws "\U+03F4"
I saw in this question that the 'u' was lowercase but that didn't make any difference.
Why would this not be working?
The general format for Java unicode escapes is
UnicodeEscape:
\ UnicodeMarker HexDigit HexDigit HexDigit HexDigit
UnicodeMarker:
u
UnicodeMarker u
Therefore correct sequence for this character in Java is \u03F4.
http://www.fileformat.info/info/unicode/char/03F4/index.htm
I think the correct way to represent a unicode character is as follows:
g.drawString("\u03f4", 100, 100);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With