js| Solution | data | database | problem | show | Chinese
These two days by the title of the problem entangled, and finally solved the
The problems encountered at that time were as follows:
Sybase running on UNIX, code unknown, JSP page display query data Chinese garbled
Pageencoding and CharSet are set, Tomcat's XML file is also set
The methods that have been tried are:
1. The String temp = rssearch.getstring (A[i]);
if (temp!= null) {
Byte[] B = temp.getbytes ("8859_1");
temp = new String (b, "GBK");
Out.print (temp);
}
2.String temp = rssearch.getstring (A[i]);
byte[] buffer = new byte[temp.length ()];
int j=0;
for (int i = 0; I<temp.length (); i++)
{
if (Temp.charat (i) >=0x100)
{
char C = Temp.charat (i);
Byte[] buf = ("" +c). GetBytes ();
Buffer[j++] = (byte) buf[0];
Buffer[j++] = (byte) buf[1];
}
Else
{
Buffer[j++] = (byte) temp.charat (i);
}
}
temp= new String (buffer, 0, J);
Why these are effective methods used in databases such as MySQL are not valid for Sybase
The reason is that the Sybase connection is different from the other JDBC database, and it needs to be marked with attributes when connected, Dburl set to
Jdbc:sybase:tds:hostname:port/dbname?charset=eucgb&jconnect_version=4
, such as my database charset=cp850, jconnect_version=3 according to their own situation to change the appropriate
In addition, the JSP page need to use the method I mentioned at the beginning of 1, so far, the Chinese problem is resolved!