客户端用DELPHI,服务端用DOTNET;
DOTNET那边全部用UTF-8接受和发送;DELPHI这边如下:
udpClient.Send(UTF8Encode(txtMsg.Text));
str1:=updClient.ReceiveString();
ustr := UTF8Encode(str1);
txtMsg.Text := ustr;
结果为:发送没问题,但接收到中文是乱码,这个该怎么处理?
DOTNET那边全部用UTF-8接受和发送;DELPHI这边如下:
udpClient.Send(UTF8Encode(txtMsg.Text));
str1:=updClient.ReceiveString();
ustr := UTF8Encode(str1);
txtMsg.Text := ustr;
结果为:发送没问题,但接收到中文是乱码,这个该怎么处理?
//发送数据(DOTNET发送)
recData = Encoding.UTF8.GetBytes("欢迎 DOTNET!");
_service.Send(recData, recData.Length, _receivePoint);
str1:=updClient.ReceiveString();
ustr := UTF8Encode(str1);//这里应该要UTF8Decode进行解码,而不是使用UTF8Encode来编码 txtMsg.Text := ustr;
var
wstr:WideString;
str1:string;
begin updClient.Send(UTF8Encode(txtMsg.Text));
str1:=updClient.ReceiveString();
wstr := UTF8Decode(str1);
txtMsg.Text := wstr;第一天用DELPHI写程序有点蒙,谢了