unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; ss : string; implementation {$R *.dfm} procedure test1(const s: string); begin try SS := '你好'; ShowMessage(s); except on E:Exception do begin ShowMessage(E.Message); end; end; end; procedure TForm1.Button1Click(Sender: TObject); begin SS := 'Hello'; Test1(ss); end; end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
ss : string;
implementation
{$R *.dfm}
procedure test1( s: string);
begin
try
SS := '你好';
ShowMessage(s);
except
on E:Exception do
begin
ShowMessage(E.Message);
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
SS := 'Hello';
Test1(ss);
end;
end.
procedure test1(const s: string);
begin
try
SS := '你好';
ShowMessage(Utf8ToAnsi(s));
except
on E:Exception do
begin
ShowMessage(E.Message);
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
SS := 'Hello';
Test1(ss);
end;