-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathURLEncode.h
More file actions
34 lines (27 loc) · 1002 Bytes
/
URLEncode.h
File metadata and controls
34 lines (27 loc) · 1002 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
34
// From:
// https://www.codeproject.com/Articles/19629/How-to-Encode-Decode-URLs-to-the-UTF8-Format-with
// URL Encoding/Decodeing class, supports Unicode and ANSI (MFC TCHAR)
// Written by Daniel Cohen Gindi, (danielgindi (at) gmail.com)
// If you have any comments or questions, feel free to email me.
// You may use this class for any purpose, commercial or personal.
#pragma once
#include "stdafx.h"
#include <atlstr.h>
// For ANSI, set default codepage to Hebrew.
// This is used for conversion into UTF-8 from ANSI (Through Unicode)
// You can change this to your codepage.
#define URLENCODE_DEFAULT_ANSI_CODEPAGE 1255
class CURLEncode
{
private:
static LPCTSTR m_lpszUnsafeString;
static int m_iUnsafeLen;
static LPCTSTR m_lpszReservedString;
static int m_iReservedLen;
CString toHex(BYTE val);
WORD toUTF8(TCHAR tc);
TCHAR fromUTF8(WORD w);
public:
CString Encode(CString strURL, BOOL bEncodeReserved=FALSE);
CString Decode(CString strURL);
};