IdUDPServer中文汉字乱码 及IdTCPClient

 

官网

http://www.indyproject.org/docsite/html/frames.html?frmname=topic&frmfile=TIdTCPServer_OnExecute.html

 

IdUDPServer1中文汉字乱码,用IndyTextEncoding_OSDefault字符编码就解决问题了

IdUDPServer1.Send(1.1.1.1,8080,'中国人',IndyTextEncoding_OSDefault);

 

发送字节

IdUDPServer1.SendBuffer(const System::UnicodeString AHost, const System::Word APort, const Idglobal::TIdBytes ABuffer);

 TIdBytes 就是TBytes就是TByteDynArray

 

 udp bytes byte

procedure TForm1.IdUDPServer1UDPRead(AThread: TIdUDPListenerThread; const AData: TIdBytes; ABinding: TIdSocketHandle);
begin
   lastMsg := BytesToString(AData, IndyTextEncoding_OSDefault);

end;

 

TCP,IdTCPClient

IndyTextEncoding

IdTCPClient1.IOHandler.WriteLn(sendData,IndyTextEncoding(TEncoding.ANSI)); 

 

bs:TBytes;

setlength(bs,8);

IdTCPClient1.IOHandler.Write(TIdBytes(bs));

 

c++

String rstr = BytesToString(AData, IndyTextEncoding_UTF8());

https://stackoverflow.com/questions/13839094/how-to-read-all-bytes-from-server-using-indy-client-in-delphi

https://forums.embarcadero.com/thread.jspa?threadID=211952

已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页