HTML character entity and escape string Encyclopedia

Source: Internet
Author: User


The composition of the escaped string

The Escape string (Escape Sequence), the character entity (Character entity), is divided into three parts: the first part is a & symbol, English is called Ampersand; the second part is the entity name or the # Add the entity number, and the third part is a semicolon.

For example, to display a less than sign (<), you can write &lt; or & #60;.

The advantage of the entity name is better understanding, a look at LT, probably guess is less than meaning, but its disadvantage is that not all browsers support the latest Entity name. The entity number can be processed by various browsers.

Tip: Entity names (entities) are case-sensitive.

Note: The same symbol can be referenced in both "Entity name" and "entity number", "Entity name" advantage is easy to remember, but does not guarantee that all browsers will be able to identify it, and "entity number" There is no such worry, but it is not easy to remember.

JavaScript escape character
Escape Sequences character
\b Backspace
\f Go paper To change pages
\ n Line break
\ r Enter
\ t Transverse jump lattice (ctrl-i)
\‘ Single quotation marks
\" Double quotes
\\ Back slash

When programming, we should pay attention to the problem of special characters, and many problems in running are caused by the appearance of special characters.

Note that because the backslash itself is used as an escape character, you cannot type a backslash directly in the script. If you want to produce a backslash, you must type a two backslash (\ \) together.


Encoding Conversion(To Unicode)

(The program code originates from the network)

JS version

<script> test = "Hello abc" str = "for" (i=0; i<test.length;    i++) {  temp = test.charcodeat (i). toString (16);      str + = "\\u" + New Array (5-string (temp). Length). Join ("0") +temp; } document.write (str) </script>

HTML Special escape character list the most commonly used character entity Character entities
Show Description Entity name Entity number
Half-square-large blank &ensp; & #8194;
The whole square big blank &emsp; & #8195;
A blank grid that keeps on line &nbsp; & #160;
< Less than &lt; & #60;
> Greater than &gt; & #62;
& & Symbols &amp; & #38;
" Double quotes &quot; & #34;
? Copyright &copy; & #169;
? Registered trademarks &reg; & #174;
? Trademark (USA) ? & #8482;
X Multiplication sign &times; & #215;
÷ Division Sign &divide; & #247;

HTML character entity and escape string Encyclopedia

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.