procedure TForm1.Button3Click(Sender: TObject);
var
s:widestring;
c:array of widechar;
n,i:integer;
begin
s:='This is 中国人';
n:=length(s);
setlength(c,n+1);
for i:=1 to n do c[i-1]:=s;
c[n]:=#0;
showmessage(c[0]);
showmessage(c[10]);
setlength(c,0);
end;
把字符串保存到UniCode文件:
var s:String;
ws:WideString;
begin
s:='是中2332hjhjfd中国';
ws:=s;//这里实现普通字符串到UniCode字符串的转换,不过如果在非中文系统下,这句就没有用了.非中文系统必须有专们的函数来转换.
With TMemoryStream.Create do
begin
try
Write(ws[1],Length(ws)*2);
Seek(0,0);
SaveToFile('C:/a.txt');
finally
Free;
end;
end;
end;