不会吧,en我用的是byte() procedure TForm1.Button1Click(Sender: TObject); var str:widestring; s:string; flag1,qu,wei,i,j:integer; begin str:=edit1.Text; for i:=1 to length(str) do begin s:=str[i]; if length(s)>1 then begin j:=word(s[1]) shl 8 + WORD(s[2]); If (j > 31) And (j < 127) Then begin qu := 161; wei := j + 161 * 2 - 6; end Else begin qu :=j div 256; wei:=j-(j div 256)*256; End; flag1:= 94 * qu + wei; flag1:= flag1 - 95 * 161; end else begin j:=byte(str[i]); end; end; end;
edit2.Text :=inttostr(ord('g'));
这么写就不行?
edit2.Text :=inttostr(ord(edit2.text));
procedure TForm1.Button1Click(Sender: TObject);
var
str:widestring;
s:string;
flag1,qu,wei,i,j:integer;
begin
str:=edit1.Text;
for i:=1 to length(str) do
begin
s:=str[i];
if length(s)>1 then
begin
j:=word(s[1]) shl 8 + WORD(s[2]);
If (j > 31) And (j < 127) Then
begin
qu := 161;
wei := j + 161 * 2 - 6;
end
Else
begin
qu :=j div 256;
wei:=j-(j div 256)*256;
End;
flag1:= 94 * qu + wei;
flag1:= flag1 - 95 * 161;
end
else
begin
j:=byte(str[i]);
end;
end;
end;