Now I have a way of solute chinese problem in java
(include jdbc-odbc bridge but as if only fit jdk 1.1.* and 1.0.*)
the way is using encoding way.the "iso-8859-1" encoding is the most wide english encoding solutionsupposing the chinese data is readed from file or database in String "sChData",
you must deal with the following code
" byte[] ch_byte = sChData.getBytes("iso-8859-1");
//here we force java vm to read chinese data in a english way
sChData = new String(ch_byte);
//and here we force to turn into unicode data",in addition, when data writed to file or db , and use the following code
" byte[] ch_byte = sChData.getBytes();
//here we divide the string into byte array
sChData = new String(ch_byte,"iso-8859-1");
//and here we force to turn to the english way from
// the unicode byte array" if you want to send data among threads, please use Reader/writer
in jdk 1.1.* or jdk 1.2.* to send the unicode data which are dealt
with the first way;the way fit in all java editions except for jdbc in jdk1.2
(it is only now I have not solutions.)
(include jdbc-odbc bridge but as if only fit jdk 1.1.* and 1.0.*)
the way is using encoding way.the "iso-8859-1" encoding is the most wide english encoding solutionsupposing the chinese data is readed from file or database in String "sChData",
you must deal with the following code
" byte[] ch_byte = sChData.getBytes("iso-8859-1");
//here we force java vm to read chinese data in a english way
sChData = new String(ch_byte);
//and here we force to turn into unicode data",in addition, when data writed to file or db , and use the following code
" byte[] ch_byte = sChData.getBytes();
//here we divide the string into byte array
sChData = new String(ch_byte,"iso-8859-1");
//and here we force to turn to the english way from
// the unicode byte array" if you want to send data among threads, please use Reader/writer
in jdk 1.1.* or jdk 1.2.* to send the unicode data which are dealt
with the first way;the way fit in all java editions except for jdbc in jdk1.2
(it is only now I have not solutions.)
String nickname;
BufferedReader reader = new BufferedReader(new InputStreamReader(new StringBufferInputStream(nickname), "GBK"));
nickname = reader.readLine();同样,将你的socket输出流也设置为类似的模式就可以了