谁帮忙写段代码,把字符串转换成ascii值的字符串

解决方案 »

  1.   

    Function XStr( Source : String ) : String;
    Var
       I : Integer;
    Begin
         Result := '';
         For I := 1 To Length( Source ) Do
         Begin
              Result := Result + IntToHex( Ord( Source[ I ] ) );
         End;
    End;
      

  2.   

    procedure TForm1.Button2Click(Sender: TObject);
    Var s,r:string;
        i:integer;
    begin
        s:=Edit2.Text;
        r:='';
        for i:=1 to Length(s) do
         r:=r+ IntTostr(Ord(s[i]));
        edit3.Text :=r;
    end;
      

  3.   

    上面是输出16进制的格式!!!
    这是输出10进制的格式!!!Function XStr( Source : String ) : String;
    Var
       I : Integer;
    Begin
         Result := '';
         For I := 1 To Length( Source ) Do
         Begin
              Result := Result + IntToStr( Ord( Source[ I ] ) );
         End;
    End;