Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About character encoding

 
Jack Lau
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

If I have a jsp file which has contentType="text/html;charset=UTF-8", and I would like to type some chinese words in the text box and submit to server and then save to db (varchar2). I try to use
new String(mytext.getBytes(request.getCharacterEncoding()), "UTF-8"); or
new String(mytext.getBytes(request.getCharacterEncoding()), "gb2312");
but the result still "???".
Could anyone know how to solve it?

Thanks in advance!
Jack
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess you might not need to do the coversion for the Strings, but you might try using:


request.setCharacterEncoding("UTF-8");


to force the request using UTF-8 encoding.

Nick
 
Ram Kumar Subramaniam
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at the character encoding of the database. If the encoding of the database is cp850 and you are trying to store unicode data then you will have a problem.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic