A very simple MFC class to Encode and Decode an url string
来源:互联网 发布:知解的成语 编辑:程序博客网 时间:2024/06/05 03:24
A very simple MFC class to Encode and Decode an url string
Tis is my contribution to encode and decode an url string; My objective was simplifying source code, using CString existing functions...
Tis is my contribution to encode and decode an url string; My objective was simplifying source code, using CString existing functions...
/*****************************************************************************Module : UrlString.hNotices: Written 2006 by Stephane ErhardtDescription: H URL Encoder/Decoder*****************************************************************************/#ifndef __CURLSTRING_H_#define __CURLSTRING_H_class CUrlString{private:CString m_csUnsafe;public:CUrlString();virtual ~CUrlString() { };CString Encode(CString csDecoded);CString Decode(CString csEncoded);};#endif //__CURLSTRING_H_/*****************************************************************************Module : UrlString.cppNotices: Written 2006 by Stephane ErhardtDescription: CPP URL Encoder/Decoder*****************************************************************************/#include "stdafx.h"#include "UrlString.h"/*****************************************************************************/CUrlString::CUrlString(){m_csUnsafe = _T("%=/"<>//^[]`+$,@:;/!#?&'");for(int iChar = 1; iChar < 33; iChar++)m_csUnsafe += (char)iChar;for(int iChar = 124; iChar < 256; iChar++)m_csUnsafe += (char)iChar;}/*****************************************************************************/CString CUrlString::Encode(CString csDecoded){CString csCharEncoded, csCharDecoded;CString csEncoded = csDecoded;for(int iPos = 0; iPos < m_csUnsafe.GetLength(); iPos++){csCharEncoded.Format(_T("%%%02X"), m_csUnsafe[iPos]);csCharDecoded = m_csUnsafe[iPos];csEncoded.Replace(csCharDecoded, csCharEncoded);}return csEncoded;}/*****************************************************************************/CString CUrlString::Decode(CString csEncoded){CString csUnsafeEncoded = Encode(m_csUnsafe);CString csDecoded = csEncoded;CString csCharEncoded, csCharDecoded;for(int iPos = 0; iPos < csUnsafeEncoded.GetLength(); iPos += 3){csCharEncoded = csUnsafeEncoded.Mid(iPos, 3);csCharDecoded = (char)strtol(csUnsafeEncoded.Mid(iPos + 1, 2), NULL, 16);csDecoded.Replace(csCharEncoded, csCharDecoded);}return csDecoded;}
- A very simple MFC class to Encode and Decode an url string
- How to use the UTF8Encoding class to encode and decode a text?
- URL Encode and URL Decode
- A simple HTTP PHP class to crawl a URL for internal and external URLs
- A very efficient and economical way to shift an array
- encode an Url to Uft8 format
- Javascript url decode, encode
- oracle url encode decode
- C++ url encode decode
- url encode decode
- ExtJs encode & decode & url
- Url decode & encode
- oracle url encode decode
- url encode 和 decode
- C++: Converting an MFC CString to a std::string
- C++: Converting an MFC CString to a std::string
- H264 encode and decode
- lua -- encode and decode
- Hashtable 示例
- STL序列式容器中删除元素的方法和陷阱一
- C++对象的拷贝与赋值操作
- 水晶报表的一些解决方法
- 在Java中操控剪切板数据- -
- A very simple MFC class to Encode and Decode an url string
- 周岁了~~生日快乐
- 浅谈ASP.NET的权限管理和用户验证
- STL序列式容器中删除元素的方法和陷阱二
- Google第一美女的工作流程 晚上12点才回家
- MySQL数据库函数详解
- 英文及数字全/半角转换
- 关于hibernate 利用c3p0连接mysql 数据库
- STL序列式容器中删除元素的方法和陷阱三