This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Svelte and Sapper in Action and have Mark Volkmann on-line!
See this thread for details.
Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

showing japanese characters

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
i am trying to insert and fetch japanese characters into the database.
i am using Oracle 9i and NLS_LANG and NLS_LANG_UTF shows JAPANESE_JAPAN.JA16SJIS and JAPANESE_JAPAN.AL16UTF-16 respectively.
i am using Windows xp sp3 English operating system .

i have a jsp page in which i have 2 text fields where i enter japanese data ,then submit it to a servlet where i do a request.getParameter("");
and then insert in the database ,same way i want to fetch the japanese data from the database and show it on my browser. i am facing a lot of problems . Can one help me out .
 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Mathew,
The default server encoding is ISO-8859-1 which is capable of handling only the western European charatcers. To handle Asians locales, you have to use Unicode(utf8) encoding.
Here is the code which will help you in retrieving values from client forms to Server.

String orig = request.getParameter(Constants.PARAM_NAME);
String real = new String(orig.getBytes(),"UTF8");
But wait this is only retriving value from the form.

Second Step :

Store the values into database(Oracle)
The database character set must be specified Unicode at the time of DATABASE CREATION. Oracle document strongly recommends to create unicode database rather than create database with default characters and then change the charset to Unicode.
For database Storage :

Use prepared statements and parse these "real" String.


Third Step :

While retriving from database :

Convert the string again to Unicode with :


String stResultset = new String(rs.getString("COLUMN_NAME") ,"UTF8");


Step 4 :
To Display this STring on the Screen :

Set the responsetype to Unicode using following line in your servlet.
response.setContentType( "text/html; charset=UTF-8" );

NOw with Printwriter Object send the "stResultset" string back to the client.

Hope this helps.

Regards,
Milind
 
mathew john
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx for the reply ,

i already have a database created . i dont know with which charset the database is installed .how do i know that ??

is it that depending on the charset the database is installed i have to encode my characters according to that.

Suppose my database is installed in shift_jis ,other than UTF-8 then what should i do ?

Can You give me some links about internationalization .
 
machines help you to do more, but experience less. Experience this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic