汉字转换成ASCII码procedure TForm1.Button1Click(Sender: TObject); var s1,s2:string; i,j:Integer; begin s1:=form1.Edit1.Text; s2:=''; i:=Length(s1); if i>0 then begin for j:=1 to i do begin s2:=s2+inttohex(Ord(s1[j]),2); end; end; form1.Edit2.Text:=s2; end;
1. 只有ASCII(American Standard Code for Information Interchange),没有ASCLL这个东西 2. ascii的编码范围是0-127,汉字不论是gb2312/18030还是unicdoe都跟ascii编码是平行的关系
var
s1,s2:string;
i,j:Integer;
begin
s1:=form1.Edit1.Text;
s2:='';
i:=Length(s1);
if i>0 then
begin
for j:=1 to i do
begin
s2:=s2+inttohex(Ord(s1[j]),2);
end;
end;
form1.Edit2.Text:=s2;
end;
2. ascii的编码范围是0-127,汉字不论是gb2312/18030还是unicdoe都跟ascii编码是平行的关系