In (x) HTML, some special characters should be HTML Entity escaping.
Common examples include: & (and), "(double quotation marks), '(single quotation marks), <(less than signs), and> (greater than signs) the HTML document content should be converted to: & amp;, & quot;, & #039;, & lt;, and & gt ;.
But the question is, why is the conversion of single quotes different from other special characters? Why is entity number (& #039;) used only in single quotes, and entity name (& apos;) used in other operations?
The reason is that the IE browser does not currently support Entity Names in single quotes, while the IE browser only supports entity numbers in single quotes.
This is also the reason why the PHP htmlspecialchars function converts single quotes to & #039; instead of & apos.
In addition, Baidu does not support Entity Names in single quotes.
Appendix: detailed records of the HTML Escape Character Table
Special characters
Character |
Decimal |
Escape characters |
" |
& Amp; #34; |
& Quot; |
& |
& #38; |
& Amp; |
< |
& #60; |
& Lt; |
> |
& #62; |
& Gt; |
Non-breaking space) |
& #160; |
& Nbsp; |
Other characters
Character |
Decimal |
Escape characters |
Character |
Decimal |
Escape characters |
Character |
Decimal |
Escape characters |
? |
& #161; |
& Iexcl; |
Á |
& #193; |
& Aacute; |
Á |
& #225; |
& Aacute; |
Bytes |
& #162; |
& Cent; |
 |
& #194; |
& Amp; CIRC; |
 |
& #226 |
& Acirc; |
Bytes |
& #163; |
& Pound; |
Bytes |
& #195; |
& Atilde; |
Bytes |
& #227; |
& Atilde; |
Bytes |
& #164; |
& Curren; |
Ä |
& #196; |
& Auml |
Ä |
& #228; |
& Auml; |
¥ |
& #165; |
& Yen; |
Bytes |
& #197; |
& Ring; |
Bytes |
& #229; |
& Aring; |
| |
& #166; |
& Brvbar; |
Bytes |
& #198; |
& Aelig; |
Bytes |
& #230; |
& Aelig; |
§ |
& #167; |
& Sect; |
C. |
& #199; |
& Ccedil; |
C. |
& #231; |
& Ccedil; |
○ |
& #168; |
& UML; |
? |
& #200; |
& Egrave; |
? |
& #232; |
& Egrave; |
|
& #169; |
& Copy; |
É |
& #201; |
& Eacute; |
É |
& #233; |
& Eacute; |
A |
& #170; |
& Ordf; |
Bytes |
& #202; |
& Ecirc; |
Bytes |
& #234; |
& Ecirc; |
? |
& #171; |
& Laquo; |
Bytes |
& #203; |
& Euml; |
Bytes |
& #235; |
& Euml; |
? |
& #172; |
& Not; |
Bytes |
& #204; |
& Igrave; |
Bytes |
& #236; |
& Igrave; |
/X7f |
& #173; |
& Shy; |
Í |
& #205; |
& Iacute; |
Í |
& #237; |
& Iacute; |
|
& #174; |
& Reg; |
Bytes |
& #206; |
& Icirc; |
Bytes |
& #238; |
& Icirc; |
Bytes |
& #175; |
& Macr; |
Bytes |
& #207; |
& Iuml; |
Bytes |
& #239; |
& Iuml; |
° |
& #176; |
& Deg; |
Bytes |
& #208; |
& ETH; |
Bytes |
& #240; |
& Ieth; |
± |
& #177; |
& Plusmn; |
N |
& #209; |
& Ntilde; |
N |
& #241; |
& Ntilde; |
2 |
& #178; |
& Sup2; |
Bytes |
& #210; |
& Ograve; |
Bytes |
& #242; |
& Ograve; |
3 |
& #179; |
& Sup3; |
Ó |
& #211; |
& Oacute; |
Ó |
& #243; |
& Oacute; |
′ |
& #180; |
& Acute; |
Bytes |
& #212; |
& Ocirc; |
Bytes |
& #244; |
& Ocirc; |
μ |
& #181; |
& Micro; |
Bytes |
& #213; |
& Otilde; |
Bytes |
& #245; |
& Otilde; |
? |
& #182; |
& Para; |
Ö |
& #214; |
& Ouml; |
Ö |
& #246; |
& Ouml; |
· |
& #183; |
& Middot; |
& Times; |
& #215; |
& Times; |
Bytes |
& #247; |
& Divide; |
? |
& #184; |
& Cedil; |
Ø |
& #216; |
& Oslash; |
Ø |
& #248; |
& Oslash; |
1 |
& #185; |
& Sup1; |
Bytes |
& #217; |
& Ugrave; |
Bytes |
& #249; |
& Ugrave; |
O |
& #186; |
& ORDM; |
Úo |
& #218; |
& Uacute; |
Úo |
& #250; |
& Uacute; |
? |
& #187; |
& Raquo; |
Bytes |
& #219; |
& Ucirc; |
Bytes |
& #251; |
& Ucirc; |
? |
& #188; |
& Frac14; |
Ü |
& #220; |
& Uuml; |
Ü |
& #252; |
& Uuml; |
? |
& #189; |
& Frac12; |
Bytes |
& #221; |
& Yacute; |
Bytes |
& #253; |
& Yacute; |
? |
& #190; |
& Frac34; |
Bytes |
& #222; |
& Thorn; |
Bytes |
& #254; |
& Thorn; |
? |
& #191; |
& Iquest; |
Bytes |
& #223; |
& Szlig; |
Bytes |
& #255; |
& Yuml; |
À |
& #192; |
& Agrave; |
À |
& #224; |
& Agrave; |
|