HTML special character escaping problem (go!) )

Source: Internet
Author: User

html, javascript, URL special character escapes in the actual programming are useful, some people on the use of special character escapes is not very clear, the following on the escape of Html,javascript,url special characters to do a description and Induction.

HTML special character escapes

HTML special character escapes are formatted as Follows:

& + Entities (entity) or # Plus entities (entity) + ";" For example,:& escaped and became & amp;

Still remember just learn HTML that will, do page layout, need to use a lot of space, so you keep pressing the space to affect the layout, but see the effect has not changed. The reason is that when HTML encounters multiple spaces between two characters, it is parsed into a single space. There are students on the point, the space for & nbsp, and then copied a large number of & nbsp, The effect is realized, think of the original HTML is how Simple.

The following are common HTML escape characters:

Character Description Escape character
" Double quotes "
& & Symbols &
< Less than &amp;amp;lt;
> Greater than &amp;amp;gt;
A blank grid that keeps on line &amp;amp;nbsp;
Single quotation marks &amp;amp;acute;
? Copyright &amp;amp;copy;
? Registered trademarks &amp;amp;reg;
Javascrpt Escape character

The following lists the commonly used escape characters in JavaScript

Escape sequences Character
\b Backspace
\f Go paper To change pages
\ n Line break
\ r Enter
\ t Horizontal Jump Grid
\‘ Single quotation marks
\" Double quotes
\\ Back slash

Note: the difference between line break (\ N) and carriage return (\ R)

The story of this thing comes from a typewriter, and there are two steps in the old typewriter to start a new line:

1. Type the head back to the starting position, this is the carriage return
2. Move the paper up one line, this is the line
URL special character escapes

When you submit the form by get, the browser will use the HTTP protocol to parse the URL parameters in the & symbol, and then upload to the server, the server gets the corresponding Value. If the & character usage is unreasonable, the server will not get the corresponding value after the HTTP protocol parsing.

For example:

http://jahan.sinaapp.com/test.php?content= me and you//content= me and you
http://jahan.sinaapp.com/test.php?content=i&you//content=i, you= ';

This violates our intentions, and what we want is i&you, so it is necessary to master and understand URL Escapes.

URL Special character encoding Formula:

URL Special character encoding formula =% + character ASCII (16 Binary) code value
For example: the encoded value of a space is "%20".

Some URL special symbols and codes are listed in the following Table.

Special characters Description 16 Binary values
+ The + sign in the URL denotes a space %2b
Space Spaces in the URL can be used with a + or code %20
/ Separating directories and subdirectories %2f
? Separating the actual URLs and parameters %3f
% Specify special characters %25
# Represents a bookmark %23
& Delimiter between the parameters specified in the URL %26
= The value of the specified parameter in the URL %3d

The above is the html, javascript, URL special character escape or coding summary, summed up, oneself also suddenly dawned, the original before appeared all sorts of problems is because this or why will deal with, hope to you, to my own help.

HTML special character escaping problem (go!) )

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.