delphi和 java通过socket通信的中文问题
在delphi中把字符串转换下
Msg:=Utf8Encode(Msg);
java中接收
java中用了mina
public static final String MSG_UTF = "UTF-8";
public static String decodeString(byte[] bytes) {
try {
return new String(bytes, MSG_UTF);
} catch (UnsupportedEncodingException e) {
throw new Error("Required character set " + MSG_UTF +
" not found", e);
}
}
把收到字节转化下,解决这个问题,hehe

本文介绍了如何在Delphi和Java之间实现通过Socket进行中文字符的正确传输。具体做法是在Delphi端使用Utf8Encode将字符串编码为UTF-8格式,在Java端利用MINA框架并指定UTF-8字符集来解码接收到的字节流。
1万+

被折叠的 条评论
为什么被折叠?



