ASP. NET Escape character

Source: Internet
Author: User

First, what is an escape character

An escape character is a special character constant, preceded by a backslash "\" followed by one or several characters. Have a specific meaning, different from the original meaning of the character, it is called "escape" character. The usual escape characters are &, \.

&lt; of HTML &gt;&amp;&quot;&copy; is <,>,&, ",; the escape character

Second, the function of the escape character

It is used primarily to denote control codes that are not easily represented by ordinary characters. Its function is to eliminate the original meaning of the character immediately following it, and to replace some special characters with some ordinary characters, because its combination changes the meaning of the original character, so it is called "Escape", and the invisible character is represented by the visible character, such as ' \ n ' indicates a newline.

In all programming languages, the reason for having escape characters is basically two points: first, use the escape character to denote characters defined in the character set, such as the control character inside the ASCLL and the character of carriage return, which have no ready-made text code. Therefore, it can only be represented by an escape character. Some specific characters are defined in the editing language as special-purpose characters. These characters have lost their original meaning because they are defined as special purposes. For example, HTML,< is defined by HTML as the beginning of the label, so when we go to <, the HTML will take it as a start, rather than as a < to see. Again, like PHP double quotation mark ("), is defined by PHP as the outer label of the string, so if you are in a pair of double quotation marks, but also want to use double quotation marks, you can only use the escape character. Otherwise, PHP will get an error.

Also for the security of the website. Some sensitive characters are escaped using the escape character (function) before the data is written to the database. This avoids the use of special symbols to inject attacks by people with ulterior motives.

Iii. escaping character symbols and their corresponding meanings

The escape character corresponds to the meaning

\ ' Single quotation mark

\ "Double quotation marks

\ \ counter Slash

Air

\a warning (generates peak)

\b Backspace

\f Page Change

\ nthe line break

\ r Enter

\ t Horizontal tab

\v Vertical Tab

For example, for example: string mystr= "volkswagen \" computer \ "learning"; The result of the output is: mass "computer" learning

\ is to escape a single character when used such as: keyword in Oracle to use double-cited and uppercase string sql= "SELECT ID," "NAME", Type,code from USER ", after escaping to string sql=" select Id,\ "name\" , Type,code from USER "; However, if you need to escape too many characters, or too confusing, especially the current path of the configuration file, it is extremely error-prone. At this point in front of the string plus @, is to tell the system @ after a string of characters, inside the things do not escape. In C #, "c:\\temp" means that the path is c:\temp; and @ "C:\Temp" means c:\temp; So, the function of @ is to ignore the escape character.

ASP. NET Escape character

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.