encodeURIComponent

IMPORTANT!  
Starting with v24.3, this is deprecated.

Percent-encodes a text string as a valid Uniform Resource Identifier based on the scheme below. Encodes the same special characters as encodeURI with the addition of # $ & + , / : ; = ? @. Also see escape.

See decodeURIComponent for information on how to decode a URIComponent-encoded string.

string encodeURI(string) encodeURIComponent(string) escape(string)
\n %0A %0A %0A
\t %09 %09 %09
space %20 %20 space
! ! ! %21
" %22 %22 %22
# # %23 %23
$ $ %24 %24
% %25 %25 %25
& & %26 %26
\' ' ' %27
( ( ( %28
) ) ) %29
* * * *
+ + %2B +
, , %2C %2C
- - - -
. . . .
/ / %2F /
0 0 0 0
1 1 1 1
2 2 2 2
3 3 3 3
4 4 4 4
5 5 5 5
6 6 6 6
7 7 7 7
8 8 8 8
9 9 9 9
: : %3A %3A
; ; %3B %3B
< %3C %3C %3C
= = %3D %3D
> %3E %3E %3E
? ? %3F %3F
@ @ %40 @
A A A A
B B B B
C C C C
D D D D
E E E E
F F F F
G G G G
H H H H
I I I I
J J J J
K K K K
L L L L
M M M M
N N N N
O O O O
P P P P
Q Q Q Q
R R R R
S S S S
T T T T
U U U U
V V V V
W W W W
X X X X
Y Y Y Y
Z Z Z Z
[ %5B %5B %5B
\\ %5C %5C %5C
] %5D %5D %5D
^ %5E %5E %5E
_ _ _ _
` %60 %60 %60
a a a a
b b b b
c c c c
d d d d
e e e e
f f f f
g g g g
h h h h
i i i i
j j j j
k k k k
l l l l
m m m m
n n n n
o o o o
p p p p
q q q q
r r r r
s s s s
t t t t
u u u u
v v v v
w w w w
x x x x
y y y y
z z z z
{ %7B %7B %7B
| %7C %7C %7C
} %7D %7D %7D
~ ~ ~ %7E

Syntax

function encodeURIComponent(uri: string): string
 
Parameter Description
uri Source string to be URIComponent-encoded.

Return Value

Returns the URIComponent-encoded string.

Examples