Reserved and unsafe characters in URLs

Source: Internet
Author: User
Tags character set reserved

Use the Us-ascii character set to display characters when writing URLs.

http://www.google.com

If you need to use a character in a URL that does not belong to this character set, you will encode the character with a special symbol.

For example: the most commonly used spaces are indicated by%20, e.g. http://www.google.com/new%20123.html

In addition to those characters that cannot be displayed, you need to encode those reserved (reserved) characters and unsafe (unsafe) characters in the URL.

The so-called reserved characters are those characters that have a particular meaning in the URL. Unsafe characters are characters that have no special meaning in the URL, but may have special meaning in the context in which the URL is located. For example, double quotation marks ("")

Partial reserved characters and unsafe characters and their URL encoding
Character Describe Usage Coding
; Semicolon Keep %3b
/ Slash Keep %2f
? Question mark Keep %3f
: Colon Keep %3a
@ "At" Symbol Keep %4o
= Equals Keep %3d
& "and" symbols Keep %26
< Less than sign Not safe %3c
> Greater than sign Not safe %3e
" Double quotes Not safe %22
# Well number Not safe %23
% Percent Sign Not safe %25
{ Left Curly Brace Not safe %7b
} Closing curly Braces Not safe %7d
| Vertical Not safe %7c
\ Reverse Slash Not safe %5c
^ Add font Not safe %5e
~ Wave Not safe %7e
[ Left Middle Bracket Not safe %5b
] Right Middle Bracket Not safe %5d
` Inverted single quotation marks Not safe %60
Space Not safe %20

MyStr = Mystr.replace ("'", "%2b")//single quotation mark

MyStr = Mystr.replace ("+", "%2b")
MyStr = Mystr.replace ("*", "%2a")
MyStr = Mystr.replace ("!", "%21")

MyStr = Mystr.replace ("$", "%24")



Here is the code reference given on the W3Schools website

The default Character-set in HTML5 is UTF-8.

From From
CharacterWindows-1252UTF-8
Space %20 %20
! %21 %21
" %22 %22
# %23 %23
$ %24 %24
% %25 %25
& %26 %26
' %27 %27
( %28 %28
) %29 %29
* %2a %2a
+ %2b %2b
, %2c %2c
- %2d %2d
. %2e %2e
/ %2f %2f
0 %30 %30
1 %31 %31
2 %32 %32
3 %33 %33
4 %34 %34
5 %35 %35
6 %36 %36
7 %37 %37
8 %38 %38
9 %39 %39
: %3a %3a
; %3b %3b
< %3c %3c
= %3d %3d
> %3e %3e
? %3f %3f
@ %40 %40
A %41 %41
B %42 %42
C %43 %43
D %44 %44
E %45 %45
F %46 %46
G %47 %47
H %48 %48
I %49 %49
J %4a %4a
K %4b %4b
L %4c %4c
M %4d %4d
N %4e %4e
O %4f %4f
P %50 %50
Q %51 %51
R %52 %52
S %53 %53
T %54 %54
U %55 %55
V %56 %56
W %57 %57
X %58 %58
Y %59 %59
Z %5a %5a
[ %5b %5b
\ %5c %5c
] %5d %5d
^ %5e %5e
_ %5f %5f
` %60 %60
A %61 %61
B %62 %62
C %63 %63
d %64 %64

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.