tags:

views:

1993

answers:

4

Is there a Delphi equivalent of .net's Url.UrlEncode()?

A: 

AFAIK you need to make your own.

Here are a few examples.

Ólafur Waage
Sorry, but this is not correct, check the other answers.
Gamecat
I stand corrected.
Ólafur Waage
+23  A: 

Look at indy IdURI unit, it has two static methods in the TIdURI class for Encode/Decode the URL.

uses
  IdURI;

..
begin
  S := TIdURI.URLEncode(str);
//
  S := TIdURI.URLDecode(str);
end;
Mohammed Nasman
boris, come on, accept this answer, I just gave it a point for being totally helpful :)
Peter Perháč
+1  A: 

Another option, is to use the Synapse library which has a simple URL encoding method (as well as many others) in the SynaCode unit.

uses
  SynaCode;
..
begin
  s := EncodeUrl( str );
//
  s := DecodeUrl( str );
end;
skamradt
A: 

In a non-dotnet environment, the Wininet unit provides access to Windows' WinHTTP encode function: InternetCanonicalizeUrl

Stijn Sanders