在java版搜索"乱码"http://community.csdn.net/Expert/ForumList_Search.asp?searchtype=2&bigclassid=54&smallclassid=5401&searchKeys=%C2%D2%C2%EB&author=&tabletype=now&Submit2=%B6%D4%D1%A1%D4%F1%B5%C4%D0%A1%C0%E0%BD%F8%D0%D0%CB%D1%CB%F7
调试欢乐多
<%!String native2Unicode(String s)
{
if (s == null || s.length() == 0)
{
return null;
}
byte[] buffer = new byte[s.length()];
for (int i = 0; i < s.length(); i++)
{
buffer[i] = (byte)s.charAt(i);
}
return new String(buffer);
}
%>
--读取数据库
<%!String unicode2Native(String s)
{
if (s == null || s.length() == 0) {
return null;
}
char[] buffer = new char[s.length() * 2];
char c;
int j = 0;
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) >= 0x100) {
c = s.charAt(i);
byte []buf = (""+c).getBytes();
buffer[j++] = (char)buf[0];
buffer[j++] = (char)buf[1];
}
else {
buffer[j++] = s.charAt(i);
}
}
return new String(buffer, 0, j);
}
%>
用上面的两个函数