Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Url Encode and HTML encode

What’s the difference between an URL Encode and a HTML Encode?

like image 916
Quintin Par Avatar asked Nov 28 '09 12:11

Quintin Par


People also ask

What is URL encode in HTML?

URL encoding converts non-ASCII characters into a format that can be transmitted over the Internet. URL encoding replaces non-ASCII characters with a "%" followed by hexadecimal digits. URLs cannot contain spaces. URL encoding normally replaces a space with a plus (+) sign, or %20.

What is HTML encoding used for?

HTML encoding is used in order for web browsers to parse non-ASCII special characters in HTML documents with the standard form. It is the process to send header information to the server so that the text is displayed as text and not as HTML codes.

What type of encoding is URL encoding?

Percent-encoding is a mechanism to encode 8-bit characters that have specific meaning in the context of URLs. It is sometimes called URL encoding. The encoding consists of substitution: A '%' followed by the hexadecimal representation of the ASCII value of the replace character.

What is %2f in 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.


2 Answers

HTML Encoding escapes special characters in strings used in HTML documents to prevent confusion with HTML elements like changing

"<hello>world</hello>"  

to

"&lt;hello&gt;world&lt;/hello&gt;" 

URL Encoding does a similar thing for string values in a URL like changing

"hello+world = hello world" 

to

"hello%2Bworld+%3D+hello+world" 
like image 59
mmx Avatar answered Oct 05 '22 18:10

mmx


urlEncode replaces special characters with characters that can be understood by web browsers/web servers for the purpose of addressing... hence URL. For instance, spaces are replaced with %20, ' = %27 etc...

See these references:

  • http://www.blooberry.com/indexdot/html/topics/urlencoding.htm
  • http://www.degraeve.com/reference/urlencoding.php

HtmlEncode replaces special characters with character strings that are recognised by the HTML engine itself to render the content of the page - things like & become &amp; or < = &lt;, > = &gt; this prevents the HTML engine from interpreting these characters as parts of the HTML markup and therefore render them as if they were strings.

See this reference:

  • http://msdn.microsoft.com/en-us/library/ms525347.aspx
like image 29
BenAlabaster Avatar answered Oct 05 '22 19:10

BenAlabaster