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;