2018-10-02 widechar widestring

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

你可能感兴趣的:(2018-10-02 widechar widestring)