I am getting a field in ByrArrayOutpuStream . I need to convert it into String and display.Actually the data in the field has japanese characters. I tried to convert using the method toString("UTF-8").But it is displaying junk characters Can anyone help me out .
Maybe use a different encoding, that does support Japanese.
Also remember that the Windows / Unix command line also does not understand some character sets like Japanese. I even had a Linux command line that didn't recognise the "�" character. If you print to System.out you may never get it to work. Does it work in a JLabel, or a JTextArea?
Also, do you have support for the Japanese character set on you Windows / Unix / ...? If not, you won't get to see any Japanese characters either.
Well, you probably first should find out how the stream's content is encoded.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
i would try UTF-16 as well. But yes, it's really best if whoever stored these bytes can tell you what encoding they use. Otherwise you can just find a list of all the encodings commonly used for Japanese, and try them all.
"I'm not back." - Bill Harding, Twister
Joined: Aug 08, 2007
I am getting the data from a UTF-8 database. I tried with common encoding we use like UTF-8, SHIFT_JIS , but its not working.
Joined: Jul 11, 2001
Originally posted by Shobha Korrapati: I am getting the data from a UTF-8 database.
What is the SQL datatype of the field, and how did you get the data into a ByteArrayOutputStream? I'm guessing it was a BLOB, in which case it's irrelevant that the database uses UTF-8 - you need to know what encoding was used by whoever created the BLOB.