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

Help needed on character encoding....

 
Po-yu Chien
Ranch Hand
Posts: 45
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 45
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic