drawString with special Unicode characters to Graphics object

From: Wolfgang (mot12345_at_alexandria.ucsb.edu)
Date: 05/31/04


Date: 31 May 2004 00:20:16 -0700

Please excuse this question from an internationalization newbie.
I have a database containing Unicode strings for Norwegian and German
place names with special characters, e.g. the letter
"ö" (UTF-8: C3 B6; an "o" with two dots above it)

Say a string variable containing placenames from the database is
called
String unicodeString;
and say the string contains the place name "Sömmerda".

Now I want to draw the Unicode string onto a Graphics object, like

   g2D_of_Image.drawString(unicodeString, x, y);

This works, except that the "ö" shows up "funny", it looks like
"ö" (rather than the "o" with two dots above it)
(Other special characters similarly show up as funny stuff);

So what do you do to make Unicode (UTF-8) show up as the proper
special character on the Graphics object?
(I'm not actually sure, but the unicode may get mangled on the way
from the database into my string "unicodeString", so perhaps the
question is bigger, how do you write a Unicode-enabled java code :-o)

Thanks for any advice.

Wolfgang,
Santa Barbara



Relevant Pages