如果[/b]和之后的字符串的长度固定,也就是如下形式:
... 20 53 40 2B 3E 5E 3C 4D 21 3B 3F 20 50 ...
... 20 53 40 2B 3E 6E 4C 5D 22 3B 3F 20 50 ...
... 20 53 40 2B 3E 7E 5C 4E 23 3B 3F 20 50 ...
那么处理就更加简单了,如下代码供你参考:
procedure TForm1.Button1Click(Sender: TObject);
var
str, temp, rs: string;
lp, le: Integer;
i: Integer;
begin
lp := Pos('', Edit1.Text); // Edit1.Text = '20 53 40 2B 3E 5E 3C 4D 21 3B 3F 20 50'
le := Length(Edit1.Text);
str := Copy(Edit1.Text, lp + 4, 12);
temp := str;
i := Pos(' ', str);
while i <> 0 do
begin
rs := rs + ' ' + IntToHex(StrToInt('$' + Copy(temp, 0, i - 1)) + $80, 2);
Delete(temp, 1, i);
i := Pos(' ', temp);
end;
Edit2.Text := Copy(Edit1.Text, 1, lp + 3) + Copy(rs, 2, 12) + Copy(Edit1.Text, 34, le - 33);
end;