xe
unit Unit3;
interface
uses
? Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
? Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
tmyarr =array of char;
? TForm3 = class(TForm)
? ? Button1: TButton;
? ? procedure Button1Click(Sender: TObject);
? private
? ? { Private declarations }
? public
? ? { Public declarations }
? end;
var
? Form3: TForm3;
implementation
{$R *.dfm}
procedure test(const arr:tmyarr);
begin
? ? arr[1] := 'X';
end;
procedure TForm3.Button1Click(Sender: TObject);
var
? A :TMYARR ;
begin
? ? SETLENGTH(A,4);
? ? ? A[0] := 'A';
? ? ? A[1] := 'B';
? ? ? A[2] := 'C';
? ? ? TEST(A);
? ? ? ShowMessage( STRING(A));
end;
end.
wwwwwwwwwwwwwwwwwwwwwww
unit Unit1;
interface
uses
? Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
? Dialogs, StdCtrls;
type
? ? tmyarr =array of? char;? //? ? tmyarr =array of widechar;
? TForm1 = class(TForm)
? ? Button1: TButton;
? ? procedure Button1Click(Sender: TObject);
? private
? ? { Private declarations }
? public
? ? { Public declarations }
? end;
var
? Form1: TForm1;
implementation
{$R *.dfm}
procedure test(const arr:tmyarr);
begin
? ? arr[1] := 'X';
end;
procedure TForm1.Button1Click(Sender: TObject);
var
? A :TMYARR ;
begin
? SETLENGTH(A,3);
? ? ? A[0] := 'A';
? ? ? A[1] := 'B';
? ? ? A[2] := 'C';? ? ?
? ? ? TEST(A);
? ? ? ShowMessage( STRING(A));? //?? ShowMessage( wideSTRING(A));
end;
end.
顯示結果不同是因為。
Delphi中最常用的字符類型是Char類型。它是上面兩種字符類型其中一種的別名。DelphiXE中,Char默認為WideChar,但在之前的版本如Delph7中,Char類型代表AnsiChar。所以在使用時要特別注意。? 以后?? Char寫為WIDECHAR???? ,? STRING寫為UNICODESTRING..
d7中有widestring 但是沒有UNICODESTRING