UDP发送中文

procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
	udp.Send('localhost', 1234, 'abc123'); // 发送字符, 这样发中文接收方会乱码
end;

procedure TForm1.SpeedButton2Click(Sender: TObject);
var
	b: TBytes;
	s: string;
begin
	s := '你好';
	b := BytesOf(s);
	udp.SendBuffer('localhost', 1234, TIdBytes(b));  // TIdBytes要引用IdGlobal.pas单元
end;

 

posted @ 2015-12-16 18:21  王云盼  阅读(570)  评论(0编辑  收藏  举报