比如空格在URL中要转换成 +
比如a='a b c';
放到URL中应该是
http://abc.com/abc.php?p=a+b+cidhttp提供了转换URL参数的方法吗?

解决方案 »

  1.   

    引用 iduri
    uese idURI
     a:='a b c';
    url:='http://abc.com/abc.php?p='+TIdURI.ParamsEncode(a);
      

  2.   

    很容易,看俺写的函数
    function EnCode(Code: string): string;
    var
      I: Integer;
      Hex: string;
    begin
      for I := 1 to Length(Code) do
        case Code[i] of
          ' ': Result := Result + '+';
          'A'..'Z', 'a'..'z', '*', '@', '.', '_', '-',
            '0'..'9', '$', '!', '''', '(', ')':
            Result := Result + Code[i];
        else
          begin
            Hex := IntToHex(ord(Code[i]), 2);
            if Length(Hex) = 2 then
              Result := Result + '%' + Hex
            else
              Result := Result + '%0' + hex;
          end;
        end;
    end;
      

  3.   

    上面那是从D7里找出来的,好象对中文操作有问题。
    小改了一下
    function EnCode(ACode: string): string;
    var
      I: Integer;
      Hex: string;
      Code: AnsiString;
    begin
      Code := AnsiString(ACode);
      for I := 1 to Length(Code) do
        case Code[i] of
          ' ': Result := Result + '+';
          'A'..'Z', 'a'..'z', '*', '@', '.', '_', '-',
            '0'..'9', '$', '!', '''', '(', ')':
            Result := Result + Code[i];
        else
          begin
            Hex := IntToHex(ord(Code[i]), 2);
            if Length(Hex) = 2 then
              Result := Result + '%' + Hex
            else
              Result := Result + '%0' + hex;
          end;
        end;
    end;
      

  4.   

    a b c ,123,98yujsdf!@##^%%^&--中文123
    -----------------》
    a+b+c+%2C123%2C98yujsdf!@%23%23%5E%25%25%5E%26--%D6%D0%CE%C4123
      

  5.   

    http://www.cnblogs.com/msn/archive/2007/09/15/894144.html