• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP/Servlet/JDBC encoding(discussion)

 
Po-yu Chien
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Almost all double byte encoding country`s java programmer should have suffered for this problem: char encoding! Java by default deals everything(in my knowledge)as Unicode, but sometimes this is quite annoying. A big5 encoded jsp page cannot access or manipulate data in database through JDBC correctly without additional coding to fix the problem. In my javabean, an additional method must be performed for every get/set operation in order to store/retrieve big5(Traditional Chinese)data correctly(I hate to do this, because my app then cannot be internationalized by using struts). I need some enlightment on this encoding thing, how may I avoid it? Isn`t UTF-8 supposed to be a care-free encoding solution?
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Isn`t UTF-8 supposed to be a care-free encoding solution?

I don't think so. I think UTF-8 is ONLY ONE byte chars.
UTF-8 character set includes seven bit ASCI and the European
(French, German etc) character sets.
I would try UTF-16 encoding.
regds.
- satya
 
Po-yu Chien
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your advise...
but does JAVA support UTF-16?
Also, which database supports UTF-16 encoding?
And, pardon me for my ignorance for this encoding thing..
where should I look for information about Unicode, and how they are treated in Java?
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Po-yu Chien:

Thanks for your advise...
but does JAVA support UTF-16?

Java doesn't make any difference between the character sets.
Everything is converted to Unicode chars.
So, yes Java supports UTF-16 char set.

Also, which database supports UTF-16 encoding?
Now that depends on what character set your DB understands.
When you create an instance or DB you will select the LOCALE/
language in which it has to be created/installed. This will control what language your DB understands.
And, pardon me for my ignorance for this encoding thing..
where should I look for information about Unicode, and how they are treated in Java?

For unicode details refer to http://www.unicode.org
All strings (chars) in Java are represented as unicode
characters.

regds.
- satya
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!