Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Standard URL encode function?

Tags:

delphi

Is there a Delphi equivalent of this .net's method:

Url.UrlEncode()

Note
I haven't worked with Delphi for several years now. As I read through the answers I notice that there are several remarks and alternatives to the currently marked answer. I haven't had the opportunity to test them so I'm basing my answer on the most upvoted.
For your own sake, do check later answers and after deciding upvote the best answer so everybody can benefit from your experience.

like image 697
Boris Callens Avatar asked Apr 22 '09 09:04

Boris Callens


People also ask

Why is %20 used in URLs?

A space is assigned number 32, which is 20 in hexadecimal. When you see “%20,” it represents a space in an encoded URL, for example, http://www.example.com/products%20and%20services.html.

Are URLs UTF-8 or ASCII?

The UTF-8 locale support addresses this need. Browsers are limited to a defined character set that can legally be used in a uniform resource locator (URL). This range is defined to be the printable characters in the ASCII character set (between hex code 0x20 and 0x7e).

What is %2f in a URL?

URL encoding converts characters into a format that can be transmitted over the Internet. - w3Schools. So, "/" is actually a seperator, but "%2f" becomes an ordinary character that simply represents "/" character in element of your url.


1 Answers

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; 
like image 66
Mohammed Nasman Avatar answered Sep 28 '22 19:09

Mohammed Nasman