• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Display problem with Japanese characters

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ???
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not a "beginning" question. Moving thread.
 
And then the entire population worshiped me like unto a god. Well, me and this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic