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 < 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 |
  |
& #8194; |
|
The whole square big blank |
  |
& #8195; |
|
A blank grid that keeps on line |
|
& #160; |
< |
Less than |
< |
& #60; |
> |
Greater than |
> |
& #62; |
& |
& Symbols |
& |
& #38; |
" |
Double quotes |
" |
& #34; |
? |
Copyright |
© |
& #169; |
? |
Registered trademarks |
® |
& #174; |
? |
Trademark (USA) |
? |
& #8482; |
X |
Multiplication sign |
× |
& #215; |
÷ |
Division Sign |
÷ |
& #247; |
HTML character entity and escape string Encyclopedia