Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 91
Expand file tree
/
Copy pathURLEncode.cpp
More file actions
Latest commit
33 lines (28 loc) · 504 Bytes
/
Copy pathURLEncode.cpp
File metadata and controls
33 lines (28 loc) · 504 Bytes
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
#include"stdafx.h"
#include"URLEncode.h"
namespaceURLEncoder
{
CString Encode(const CString& str)
{
CW2Autf8str(str, CP_UTF8);
CString result;
for(int i = 0; utf8str[i] != L'\0'; i++)
{
char c = utf8str[i];
if(
(c >= 'a' && c <= 'z') ||
(c >= 'A' && c <= 'Z') ||
(c >= '0' && c <= '9') ||
c == '-' || c == '_' || c == '.' || c == '~'
)
{
result += c;
}
else
{
result.AppendFormat(L"%%%02X", (DWORD)(BYTE)c);
}
}
return result;
}
}