在编写C/S程序时,为什么不能传输汉字?应如何解决?!!!!

mjs2000 2000-08-18 09:45:00
...全文
124 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Kevin_qing 2000-08-18
  • 打赏
  • 举报
回复
用2进制流方式传不会有问题
Kevin_qing 2000-08-18
  • 打赏
  • 举报
回复
或者象下面的代码也可以使Reader可以读中文
String nickname;
BufferedReader reader = new BufferedReader(new InputStreamReader(new StringBufferInputStream(nickname), "GBK"));
nickname = reader.readLine();

同样,将你的socket输出流也设置为类似的模式就可以了
Kevin_qing 2000-08-18
  • 打赏
  • 举报
回复
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 solution

supposing 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.)

mjs2000 2000-08-18
  • 打赏
  • 举报
回复
请具体的讲解一下,谢谢了

62,612

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧