File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes About character encoding Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "About character encoding" Watch "About character encoding" New topic

About character encoding

Jack Lau
Ranch Hand

Joined: Aug 30, 2002
Posts: 168
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!
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
I guess you might not need to do the coversion for the Strings, but you might try using:


to force the request using UTF-8 encoding.


SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
Ram Kumar Subramaniam
Ranch Hand

Joined: Jan 17, 2003
Posts: 68
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.
I agree. Here's the link:
subject: About character encoding
jQuery in Action, 3rd edition