FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
ArduinoHttpClient/src/URLEncoder.cpp at master · arduino-libraries/ArduinoHttpClient · GitHub
arduino-libraries
/
ArduinoHttpClient
Public
forked from
amcewen/HttpClient
Notifications
You must be signed in to change notification settings
Fork
175
Star
317
Code
Issues
51
Pull requests
15
Actions
Projects
Wiki
Security and quality
2
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
ArduinoHttpClient
/
src
/
URLEncoder.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
53 lines (39 loc) · 1.1 KB
Breadcrumbs
ArduinoHttpClient
/
src
/
URLEncoder.cpp
Copy path
File metadata and controls
53 lines (39 loc) · 1.1 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//
Library to simplify HTTP fetching on Arduino
//
(c) Copyright Arduino. 2019
//
Released under Apache License, version 2.0
#
include
"
URLEncoder.h
"
URLEncoderClass::URLEncoderClass
()
{
}
URLEncoderClass::~URLEncoderClass
()
{
}
String
URLEncoderClass::encode
(
const
char
* str)
{
return
encode
(str,
strlen
(str));
}
String
URLEncoderClass::encode
(
const
String& str)
{
return
encode
(str.
c_str
(), str.
length
());
}
String
URLEncoderClass::encode
(
const
char
* str,
int
length)
{
String encoded;
encoded.
reserve
(length);
for
(
int
i =
0
; i < length; i++) {
char
c = str[i];
const
char
HEX_DIGIT_MAPPER
[] = {
'
0
'
,
'
1
'
,
'
2
'
,
'
3
'
,
'
4
'
,
'
5
'
,
'
6
'
,
'
7
'
,
'
8
'
,
'
9
'
,
'
A
'
,
'
B
'
,
'
C
'
,
'
D
'
,
'
E
'
,
'
F
'
};
if
(
isAlphaNumeric
(c) || (c ==
'
-
'
) || (c ==
'
.
'
) || (c ==
'
_
'
) || (c ==
'
~
'
)) {
encoded += c;
}
else
{
char
s[
4
];
s[
0
] =
'
%
'
;
s[
1
] =
HEX_DIGIT_MAPPER
[(c >>
4
) &
0xf
];
s[
2
] =
HEX_DIGIT_MAPPER
[(c &
0x0f
)];
s[
3
] =
0
;
encoded += s;
}
}
return
encoded;
}
URLEncoderClass URLEncoder;
Back
|
FazBrowse Home
|
New Git URL