• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Help needed on character encoding....

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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....
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic