为什么 TIdTextEncoding.Default 未申报?

Why is TIdTextEncoding.Default undeclared?

我试图构建我从 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 10.6 中删除,如 Indy ChangeLog blog:

中所述

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