URLSpecial characters in
URLThe special characters inURLAnd must be encoded. The encoding format is:%Character-addedASCIIA percent sign.%, Followed by the corresponding charactersASCII(16In hexadecimal notation.
Character |
Name |
16Hexadecimal value |
+ |
URLIn+Space |
% 2B |
Space |
URLSpace in can be used+ID or code |
% 20 |
/ |
Split directories and subdirectories |
% 2f |
? |
Separate the actualURLAnd Characters |
% 3f |
% |
Special characters |
% 25 |
# |
Indicates bookmarks,URLTransmission Parameters are automatically truncated.#Subsequent content |
% 23 |
& |
URLParameter Separator in |
% 26 |
= |
UELParameter value specified in |
% 3d |
Example: to pass a string"This % is # Te = sT & o k? + /"As a parameterTPassTe. asp, ThenURLYes:
Te. asp? T = This % 25is % 23te % 3dst % 26o % 20 K % 3f % 2B % 2fOr
Te. asp? T = This % 25is % 23te % 3dst % 26o + K % 3f % 2B % 2f(Space can be used% 20Or+)
JavaMediumURLEncoding and decoding Functions:
Java.net. urlencoder. encode (string S)AndJava.net. urldecoder. Decode (string S );
InJavascriptMediumURLThe encoding and decoding functions areEscape (string S)AndUnescape (string S );
HtmlEscape characters in
Character |
Escape characters |
Description |
& |
& Amp; |
And |
< |
& Lt; |
Yu no. |
> |
& Gt; |
Yu no. |
" |
& Quot; |
Double quotation marks |
' |
& Amp; #39; |
Single quotes |
Space |
& Nbsp; |
Space |
? |
& Copy; |
Copyright token |
? |
& Reg; |
Register character |
The former is the character escape sequence, and the latter is the numerical escape sequence. Convert a number to a characterASCIICode value. For example& Lt; font & gt;Displayed,<Font>Is considered as a link sign.
Note:
A.There cannot be spaces between characters in the escape sequence;
B.The escape sequence must start";"End;
C.Separate&It is not considered as the start of escape;
D.Case sensitive.
Another character that needs to be escaped is the quotation mark, and its turn-to-order Column"""Or"""
HtmlThe character set used isISO & 859 Larin-1Character Set, which contains many characters that cannot be entered on the standard keyboard. Only escape sequences can be used for these special characters.
XMLSpecial characters in
Character |
Escape characters |
Description |
& |
& Amp; |
And |
< |
& Lt; |
Yu no. |
> |
& Gt; |
Yu no. |
" |
& Quot; |
Double quotation marks |
' |
& Apos; |
Single quotes |
InvalidXMLCharacters must be escaped.XMLSimilar"<"Character,The parser will have an error, because the parser will think this is the beginning of a new element. So it should not be written as belowCode:
<Message> If salary <1000 then </message>
To avoid this"<"Convert to entity, as shown below:
<Message> If salary <1000 then </message>
JavascriptEscape characters in
Escape Sequence |
Character |
\ B |
Return |
\ F |
Take the form of paper |
\ N |
Line feed |
\ R |
Enter |
\ T |
Horizontal hop |
\" |
Double quotation marks |
\' |
Single quotes |
\\ |
Backslash |
VaR TXT = "we are the so-called" Vikings "from the north ."
Document. Write (txt)
InJavascriptThe string starts and ends with double quotation marks or single quotation marks. This means that the above string will be chopped: We are the so-called
To solve this problem, you mustVikingAdd a backslash before and after double quotation marks(\)In this way, every double quotation mark is converted into a string text:
VaR TXT = "we are the so-called \" Vikings \ "from the north ."
Document. Write (txt)
NowJavasscriptThe string can be correctly displayed:We are the so-called"Vikings"From the north.
Here is another example:
Document. Write ("You \ & me are singing !")
The above example will generate the following output:
You & me are singing!
CookieSpecial characters in
version 0: by Netscape developed by the Company, it is also supported by almost all browsers . java to maintain compatibility , currently only versions are supported. 0, Cookie content cannot contain spaces, square brackets, Parentheses, equal to signs ( = ), comma, double quotation mark, slash, question mark, @ symbol, colon, semicolon.
version 1: according to RFC 2109 (http://www.ietf.org/rfc/rfc2109.txt) . many restrictions are relaxed . restrictions listed above . but to maintain compatibility , avoid using these special characters.