Why do computers sometimes change special characters like “&” into “&” or “ ”

181 views

Why do computers sometimes change special characters like “&” into “&” or “ ”

In: 77

9 Answers

Anonymous 0 Comments

This phenomenon is exclusive to the HTML format used on the world-wide web. It defines a set of reserved characters to express its syntax, to indicate the start of code words. An example of a code word is <em> for start of *emphasized text*. Other unusual characters are unsafe to use or may hold a special meaning in file systems or other computer languages on the back end of the web server.

To transmit these characters they are substituted by these replacement strings called entities. Every web browser has a list of them, and replaces them with the corresponding character before displaying the web page. The mathematical symbols <> are “less than” and “greater than” are encoded as &lt; and &gt;. &amp; stands for “ampersand” and &nbsp; is a non-breaking space, which doesn’t allow to wrap text to a new line at that point.

When you see these special strings, a mistake has happened in the code of the website. It may have converted a character twice. & -> &amp; -> &amp;amp; When the browser receives the string “&amp;amp;”, it performs the task of restoring the complete “entity” in the first 5 characters, resulting in “&amp;” being output. Other possibilities is the encoding of the ampersand using a numerical character code, or omission of the semicolon.

You are viewing 1 out of 9 answers, click here to view all answers.