File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Issue with Form Input in JSP Request with japaneese characters

 
echarish Kumar
Ranch Hand
Posts: 44
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, i am working on a Japaneese Project and have a JSP developed in Struts, i am facing a issue with the input character, i have set the Request Encoding as SHIFT_JIS and whenever i submit a characte '-'(\uff0d) it gets converted into '−'(\u2212), i want to stop this automatic conversion from happening, regarding which i need help i.e. how to impliment a solution which will stop this conversion on the whole application.
 
Gamini Sirisena
Ranch Hand
Posts: 378
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where and how exactly are you setting the encoding as SHIFT_JIS ?
 
Ravi Majety
Ranch Hand
Posts: 59
Eclipse IDE Java Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use the encoding as "UTF-8" instead of SHIFT_JIS
 
echarish Kumar
Ranch Hand
Posts: 44
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have created a Filter which set the request encoding as SHIFT_JIS, if i set this encoding to UTF-8 the input japaneese characters become junk. i am not able to find a proper solution to this.

req.setCharacterEncoding("SHIFT_JIS");

i have to set this to get the input japaneese characters properly but due to this '-'(\uff0d) is getting changed to '−'(\u2212)
 
Gamini Sirisena
Ranch Hand
Posts: 378
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you check what is the Content-Type in the http request is?

You could do this by using firfox and and the firebug plugin.
Look under the Net tab in firebug. You could also use some other tcp monitoring tool..
 
echarish Kumar
Ranch Hand
Posts: 44
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Response Headersview source
Charset is UTF-8

Server Apache-Coyote/1.1
Set-Cookie JSESSIONID=66A8EE3E764AC0230EAE66B2AC3B1742;
Content-Type text/html;charset=UTF-8
Transfer-Encoding chunked
Date Tue, 24 May 2011 12:19:44 GMT
Request Headersview source
Host localhost:8080
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip, deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 115
Connection keep-alive
 
Gamini Sirisena
Ranch Hand
Posts: 378
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm.. if the content is encoded as UTF-8 shouldn't it be read as UTF-8?

You say when you set this to UTF-8 the japanese input characters become junk.
Could you explain how exactly you see this junk? Is it through some console?
 
echarish Kumar
Ranch Hand
Posts: 44
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
m able to see the the junk in the debug mode of the eclipse, and also when i take this input and display them again on next jsp they come out as junk.
 
Gamini Sirisena
Ranch Hand
Posts: 378
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
would you be able to print this out on the eclipse console?
For this do the following and see..

Read the characters as UTF-8

Run | Debug Configurations | Select tab Common
Under encoding select other and UTF-8

You may also have to do the following too..
Go to Eclipse > Preferences > General > Appearance > Colors & Fonts > Debug > Console font
choose a Unicode font see if Arial Unicode MS is available...

Really these are a few shots in the dark..
 
Gamini Sirisena
Ranch Hand
Posts: 378
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Echarish, have you made any progress?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic