• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Display problem with Japanese characters

 
Bhavani Kumar
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am fetching a Japanese string from Oracle Database and displaying it on the browser. But the characters are shown on the browser like ???. Inserted the Japanese string into DB using the unistr() function.INSERT INTO MESSAGES (MESSAGE_ID,MESSAGE) VALUES (1,unistr('\0041\0063\0063\0065\0073\0073\0020\004d\0061\006e\0061\0067\0065\006d\0065\006e'));

I got this in my jvm logs 'ISO8859-1' when I printed System.getProperty("file.encoding").

select * from v$nls_parameters where parameter in ('NLS_CHARACTERSET') yields 'UTF8' in my DB.

Any pointers on how the Japanese characters could be displayed correctly ?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But the characters are shown on the browser like ???

I think that you have to check the following first, to understand whether the problem comes from inserting, fetching or displaying:
1. Using an SQL editor, check the content of the database. Make sure the string is properly inserted. (I wonder why you are using unicode strings like this...)
2. What does the String contains after fetching data from the DB ? Either debug it, or output the String in a file and open the file with an editor which supports unicode.
3. How did you set the web page encoding ?
 
Paul Clapham
Sheriff
Posts: 21000
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at this article: Character Conversions from Browser to Database.
 
Bhavani Kumar
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Using an SQL editor, check the content of the database. Make sure the string is properly inserted. (I wonder why you are using unicode strings like this...)
2. What does the String contains after fetching data from the DB ? Either debug it, or output the String in a file and open the file with an editor which supports unicode.
3. How did you set the web page encoding ?


1. Japanese string is properly inserted in the DB. I had read in Oracle Technical Network that non-ascii strings could be inserted in this way. When I query this string using "select unistr('\0041\0063\0063\0065\0073\0073\0020\004d\0061\006e\0061\0067\0065\006d\0065\006e1\006e\0061\0067\0065\006d\0065\006e\0074\0020\0054\006f\006f\006c\0020\304b\3089\306e') from dual;" then it is showing me the correct japanese message.
2. String contains all ???. I saw printing it on the browser as well as in the log.
3. Web page encoding is set in the Websphere server that we use and is set to 'ISO8859-1'.

I have tried converting the mydatabasestring to correct japanese string in below ways but still only question marks (???) appear.

out.println("1."+new String(mydatabasestring.getBytes("UTF-8"),"ISO-2022-JP"));
out.println("2."+new String(mydatabasestring.getBytes("ISO-2022-JP"),"UTF-8"));
out.println("3."+new String(mydatabasestring.getBytes("ISO-2022-JP"),"ISO-2022-JP"));
out.println("4."+new String(mydatabasestring.getBytes("Cp1252"),"Cp1252"));
out.println("5."+new String(mydatabasestring.getBytes("ISO-2022-JP"),"Cp1252"));
out.println("6."+new String(mydatabasestring.getBytes("Cp1252"),"ISO-2022-JP"));
out.println("7."+new String(mydatabasestring.getBytes("UTF-8"),"Cp1252"));
out.println("8."+new String(mydatabasestring.getBytes("Cp1252"),"UTF-8"));

Is there anything that I am missing here ???
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not a "beginning" question. Moving thread.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic