gpt4 book ai didi

delphi - 为什么 TIdTextEncoding.Default 未声明?

转载 作者:行者123 更新时间:2023-12-03 17:47:20 26 4
gpt4 key购买 nike

我尝试构建从 http://sourceforge.net/projects/indy10clieservr/ 获得的第一个客户端项目但它说第 62 行的 TIdTextEncoding 和 Default 都未声明。我没有任何机会,所以这可能是什么原因造成的?

完整代码:
界面

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdGlobal;

type
TClientForm = class(TForm)
CheckBoxConnectDisconnet: TCheckBox;
ButtonSendString: TButton;
Edit1: TEdit;
Memo1: TMemo;
IdTCPClient1: TIdTCPClient;
procedure CheckBoxConnectDisconnetClick(Sender: TObject);
procedure ButtonSendStringClick(Sender: TObject);
procedure IdTCPClient1Connected(Sender: TObject);
procedure IdTCPClient1Disconnected(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
ClientForm: TClientForm;

implementation

{$R *.dfm}

{ TForm1 }

procedure TClientForm.ButtonSendStringClick(Sender: TObject);
var
LLine: String;
begin

IdTCPClient1.IOHandler.WriteLn(Edit1.Text, TIdTextEncoding.Default);
Edit1.Text := '';
LLine := IdTCPClient1.IOHandler.ReadLn();
if ( LLine = 'OK' ) then
Memo1.Lines.Add('Server says it has received your String');

end;

procedure TClientForm.CheckBoxConnectDisconnetClick(Sender: TObject);
begin
if ( CheckBoxConnectDisconnet.Checked = True ) then
begin
IdTCPClient1.Host := '127.0.0.1';
IdTCPClient1.Port := 6000;
IdTCPClient1.Connect;
end
else
IdTCPClient1.Disconnect;
end;

procedure TClientForm.IdTCPClient1Connected(Sender: TObject);
begin
Memo1.Lines.Add('Client connected with server');
end;

procedure TClientForm.IdTCPClient1Disconnected(Sender: TObject);
begin
Memo1.Lines.Add('Client disconnected from server');
end;

end.

最佳答案

这个项目在 sourceforge 主页上只列出了 Delphi 2010、XE 和 XE2,所以我猜它还没有更新到较新的 Indy 版本。
TIdTextEncoding如 Indy ChangeLog blog 中所述,已在 Indy 10.6 中删除:

Indy 10.6 has been released

the IdGlobal.TIdTextEncoding class has been replaced with a new IdGlobal.IIdTextEncoding refcounted interface that no longer depends on SysUtils.TEncoding (Embarcadero) or System.Text.Encoding (.NET) anymore (though there are wrappers provided if you still need to use them with Indy). Consequently, the IndyXXXEncoding() functions have been deprecated in favor of new IndyTextEncoding_XXX() functions.



Indy 10.6 引入了一个新的 IndyTextEncoding_OSDefault()用作 TIdTextEncoding.Default 的替代品. (见 here)

关于delphi - 为什么 TIdTextEncoding.Default 未声明?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28544592/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com