Common escape html, JavaScript escape

HTML character entities (Character Entities), escape string (Escape Sequence)

Why use escape strings?

HTML, <,>, etc. have a special meaning & (<,>, check for a link, for & escape), can not be used directly. These symbols are not displayed on the page to see where we end up, that if we want to display these symbols on the page, how to do it?

This comes to HTML escaped string (Escape Sequence) a.

Escape string (Escape Sequence), also known as character entities (Character Entity). In the HTML, there are two reasons defined escape character string: The first reason is like "<" and ">" symbols have been used to denote such HTML tags, and therefore can not be used directly as symbols used in the text . In order to use these symbols in an HTML document, you need to define it escaped string. When the interpreter encounters such strings put it interpreted as a real character. When entering escaped string, to strictly abide by the rules of capitalization. The second reason is that some characters in the ASCII character set is not defined, it is necessary to use the escape string to represent.

Composition escape string

Escape strings (Escape Sequence), i.e. entity character (Character Entity) is divided into three parts: The first part is an ampersand, English called ampersand; the second portion is an entity (Entity) or the name of # plus entity (Entity) Number ; third part is a semicolon.

For example, to display less than (<), can be written & lt; or & # 60;.

Benefits Entity (Entity) name is easier to understand, to see lt, probably guess is less than the meaning, but the disadvantage is that not all browsers support the latest Entity name. The entity (Entity) number, various browsers can handle.

Tip: name of the entity (Entity) is case-sensitive.

Note: The same symbol can be referenced with the "real name" and "real number" two ways, "the name of the entity" has the advantage of easy to remember, but can not guarantee that all browsers can successfully recognize it, while "real number" there is no such fears, but it is really hard to remember.

How to display blank?

In general, HTML is automatically cut off the excess space. No matter how much space you add, it is seen as a space. For example, you add 10 spaces between words, HTML truncates nine spaces, but one. In order to increase the space on the page, you can use the & nbsp; indicates a space.

HTML special escape characters

The most common character entity
Character Entities

display Explanation Entity name Entity Number
  Fangda half empty &ensp; &#8194;
  All parties large blank &emsp; &#8195;
  Continue the line of whitespace &nbsp; &#160;
< Smaller than &lt; &#60;
> more than the &gt; &#62;
& &symbol &amp; &#38;
" Double quotes &quot; &#34;
© copyright &copy; &#169;
® Registered Trademark &reg; &#174;
Trademarks (United States) &#8482;
× Multiplication sign &times; &#215;
÷ Sign of division &divide; &#247;

ISO 8859-1 (Latin-1) character set

HTML 4.01 supports ISO 8859-1 (Latin-1) character set.

Note: For convenience, the following table, the "entity name" referred to as the "Name", "real number" simply "No."

display name Numbering display name Numbering display name Numbering display name Numbering display name Numbering
      ¡ &iexcl; &#161; ¢ &cent; &#162; £ &pound; &#163; ¤ &curren; &#164;
¥ &yen; &#165; ¦ &brvbar; &#166; § &sect; &#167; ¨ &uml; &#168; © © ©
ª &ordf; &#170; « & Laquo; &#171; ¬ &not; &#172;   &shy; &#173; ® &reg; &#174;
¯ &macr; &#175; ° & You; &#176; ± &plusmn; &#177; ² &sup2; &#178; ³ &sup3; &#179;
´ &acute; &#180; m &micro; &#181; &para; &#182; · &middot; &#183; ¸ &cedil; &#184;
¹ &sup1; &#185; º &ordm; &#186; » &raquo; &#187; ¼ &frac14; &#188; ½ &frac12; &#189;
¾ &frac34; &#190; ¿ & Iquest; &#191; AT & Agrave; &#192; In &Aacute; &#193; Â &Acirc; &#194;
à & Abreve; &#195; Ä &Auml; &#196; To &Aring; &#197; Æ & AElig; &#198; Ç &Ccedil; &#199;
IS & Egrave; &#200; IT'S &Eacute; &#201; WILL &Ecirc; &#202; E & Euml; &#203; Ì &Igrave; &#204;
The &Iacute; &#205; Î & Icirc; &#206; Ï & Iuml; &#207; Ð &ETH; &#208; Ñ & Nacute; &#209;
o & Ograve; &#210; From &Oacute; &#211; UMBRELLA &Ocirc; &#212; Õ & Ohungarumlaut; &#213; Ö & Ouml; &#214;
× &times; &#215; Ø & Oslash; &#216; Ù & Uring; &#217; O & Uacute; &#218; And & Sinketh &#219;
Ü &Uuml; &#220; Italy &Yacute; &#221; Þ &THORN; &#222; ß &szlig; &#223; at & Germandbls; &#224;
on &aacute; &#225; â &acirc; &#226; ã & Abreve; &#227; ä &auml; &#228; to &aring; &#229;
æ & Aelig; &#230; ç &ccedil; &#231; is & Egrave; &#232; It's &eacute; &#233; will &ecirc; &#234;
e & Euml; &#235; ì &igrave; &#236; in &iacute; &#237; î & Icirc; &#238; ï & Iuml; &#239;
amide &eth; &#240; ñ & Nacute; &#241; o & Oacute; &#242; from &oacute; &#243; umbrella &ocirc; &#244;
õ & Oacute; &#245; ö & Ouml; &#246; ÷ &divide; &#247; ø &oslash; &#248; ù &ugrave; &#249;
ú &uacute; &#250; û &ucirc; &#251; ü &uuml; &#252; ý &yacute; &#253; þ &thorn; &#254;
ÿ &yuml; &#255;

数学和希腊字母标志
symbols, mathematical symbols, and Greek letters

显示 名称 编号 显示 名称 编号 显示 名称 编号 显示 名称 编号 显示 名称 编号
ƒ &fnof; &#402; Α &Alpha; &#913; Β &Beta; &#914; Γ &Gamma; &#915; Δ &Delta; &#916;
Ε &Epsilon; &#917; Ζ &Zeta; &#918; Η &Eta; &#919; Θ &Theta; &#920; Ι &Iota; &#921;
Κ &Kappa; &#922; Λ &Lambda; &#923; Μ &Mu; &#924; Ν &Nu; &#925; Ξ &Xi; &#926;
Ο &Omicron; &#927; Π &Pi; &#928; Ρ &Rho; &#929; Σ &Sigma; &#931; Τ &Tau; &#932;
Υ &Upsilon; &#933; Φ &Phi; &#934; Χ &Chi; &#935; Ψ &Psi; &#936; Ω &Omega; &#937;
α &alpha; &#945; β &beta; &#946; γ &gamma; &#947; δ &delta; &#948; ε &epsilon; &#949;
ζ &zeta; &#950; η &eta; &#951; θ &theta; &#952; ι &iota; &#953; κ &kappa; &#954;
λ &lambda; &#955; μ &mu; &#956; ν &nu; &#957; ξ &xi; &#958; ο &omicron; &#959;
π &pi; &#960; ρ &rho; &#961; ς &sigmaf; &#962; σ &sigma; &#963; τ &tau; &#964;
υ &upsilon; &#965; φ &phi; &#966; χ &chi; &#967; ψ &psi; &#968; ω &omega; &#969;
? &thetasym; &#977; ? &upsih; &#978; ? &piv; &#982; &bull; &#8226; &hellip; &#8230;
&prime; &#8242; &Prime; &#8243; &oline; &#8254; &frasl; &#8260; &weierp; &#8472;
&image; &#8465; &real; &#8476; &trade; &#8482; &alefsym; &#8501; &larr; &#8592;
&uarr; &#8593; &rarr; &#8594; &darr; &#8595; &harr; &#8596; &crarr; &#8629;
&lArr; &#8656; &uArr; &#8657; &rArr; &#8658; &dArr; &#8659; &hArr; &#8660;
&forall; &#8704; &part; &#8706; &exist; &#8707; &empty; &#8709; &nabla; &#8711;
&isin; &#8712; &notin; &#8713; &ni; &#8715; &prod; &#8719; &sum; &#8721;
&minus; &#8722; &lowast; &#8727; &radic; &#8730; &prop; &#8733; &infin; &#8734;
&ang; &#8736; &and; &#8743; &or; &#8744; &cap; &#8745; &cup; &#8746;
&int; &#8747; &there4; &#8756; &sim; &#8764; &cong; &#8773; &asymp; &#8776;
&ne; &#8800; &equiv; &#8801; &le; &#8804; &ge; &#8805; &sub; &#8834;
&sup; &#8835; &nsub; &#8836; &sube; &#8838; &supe; &#8839; &oplus; &#8853;
&otimes; &#8855; &perp; &#8869; &sdot; &#8901; ? &lceil; &#8968; ? &rceil; &#8969;
? &lfloor; &#8970; ? &rfloor; &#8971; ? &lang; &#9001; ? &rang; &#9002; &loz; &#9674;
&spades; &#9824; &clubs; &#9827; &hearts; &#9829; &diams; &#9830;

重要的国际标记
markup-significant and internationalization characters

显示 名称 编号 显示 名称 编号 显示 名称 编号 显示 名称 编号 显示 名称 编号
" &quot; &#34; & &amp; &#38; < &lt; &#60; > &gt; &#62; Π&OElig; &#338;
œ &oelig; &#339; Š &Scaron; &#352; š &scaron; &#353; Ÿ &Yuml; &#376; ˆ &circ; &#710;
˜ &tilde; &#732; &ensp; &#8194; &emsp; &#8195; &thinsp; &#8201; &zwnj; &#8204;
&zwj; &#8205; &lrm; &#8206; &rlm; &#8207; &ndash; &#8211; &mdash; &#8212;
&lsquo; &#8216; &rsquo; &#8217; &sbquo; &#8218; &ldquo; &#8220; &rdquo; &#8221;
&bdquo; &#8222; &dagger; &#8224; &Dagger; &#8225; &permil; &#8240; &lsaquo; &#8249;
&rsaquo; &#8250; &euro; &#8364;

JavaScript转义符

转义序列 字符
\b 退格
\f 走纸换页
\n 换行
\r 回车
\t 横向跳格 (Ctrl-I)
\' 单引号
\" 双引号
\\ 反斜杠

编程的时候要注意特殊字符的问题,很多运行时出现的问题都是因为特殊字符的出现而引起的。

注意,由于反斜杠本身用作转义符,因此不能直接在脚本中键入一个反斜杠。如果要产生一个反斜杠,必须一起键入两个反斜杠 (\\)。

 

Guess you like

Origin www.cnblogs.com/niuyaomin/p/11543269.html
Recommended