aspose file tools*
The moose likes JDBC and the fly likes Help needed on character encoding.... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Help needed on character encoding...." Watch "Help needed on character encoding...." New topic
Author

Help needed on character encoding....

Po-yu Chien
Ranch Hand

Joined: Nov 01, 2001
Posts: 45
I use db2 7.1 Traditional Chinese version for database storage, and my application server is Resin, which has no problem in displaying chinese correctly. However, the data retrieved from db2 cannot display big5 characters correctly. I tried setting storage charset in both big5 and UTF-8, but both failed to store
big5 character correctly.I also tried String.getBytes('BIG5'), but still fail to store big5 character in db2. I`d like to hear some advise, and thanks in advance....
zou xiao fei
Greenhorn

Joined: Oct 26, 2001
Posts: 9
protected String DealString(String sBIG5)
{
try
{
sBIG5.trim();
byte[] sReguest = sBIG5.getBytes("8859_1");
return new String(sReguest,"BIG5");
}
catch(Exception e)
{
debugError("Error in dealString"+e.toString ());
return sBIG5;
}
}
Po-yu Chien
Ranch Hand

Joined: Nov 01, 2001
Posts: 45
Thanks, now I solved the storage problem....
However, I still cannot get data correctly from db2.
I guess that`s because the default DB2Driver setting gets data in Unicode. Data displyed int jsp pages are replaced by ???
instead of chinese. So I made little modification to your code,
hoping that it would work:
protected String DealString(String sBIG5){
try{
sBIG5.trim();
byte[] sReguest = sBIG5.getBytes("UTF-8");
return new String(sReguest,"BIG5");
}catch(Exception e){
e.printStackTrace();
return sBIG5;
}
}
However I still fail. The difference is that those ??? are now even more peculiar characters.
Some insight?
[This message has been edited by Po-yu Chien (edited November 18, 2001).]
zou xiao fei
Greenhorn

Joined: Oct 26, 2001
Posts: 9
hi:
I think you can try by two steps:
1.don't display chinese characters in jsp,just try java application,using System.out.println to check if it's correctly displayed.
2.if in application it's right,try to modify the meta part of jsp
and use
meta http-equiv="Content-Type" content="text/html; charset=big5"
or you may just try view--encoding in ie

[This message has been edited by zou xiao fei (edited November 19, 2001).]
[This message has been edited by zou xiao fei (edited November 19, 2001).]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Help needed on character encoding....