Click here to Skip to main content
15,886,075 members
Articles / Desktop Programming / MFC

Auto-Task Tool for Web Game Travian

Rate me:
Please Sign up or sign in to vote.
4.84/5 (26 votes)
29 Oct 20075 min read 781.6K   7.1K   45  
Developing Auto-Task Tool for Web Game Travian
/*****************************************************************************
Module :     URLEncDec.H
Notices:     Initially Written 2002 by ChandraSekar Vuppalapati.
			 2007.3.1 Re-written by Ling, Xiao-li.  Mailto: ling.xiaoli.s@gmail.com
Description: 2007.7.22, Ling, Xiao-li.
			 Encode/Decode input ansi or mbcs string. 
			 You must call this class after convertting wide char string to multiple bytes string if input string
			 is wide char string as what API MultiByteToWideChar() does.

			 Keep in mind: 
			 string that needs to transport on Internet is different from on local system.
			 When URL Encoding applies, it only recognizes bytes, that is, when your local 
			 system adopts MBCS, the string not needs to change before URL Encoding, but if
			 your local system adopts UNICODE (wide char), then you should convert it to some
			 transportation charset (depends on Web Server side) before URL encoding, the most 
			 used UNICODE transportation charset is UTF-8 which takes one byte as encoding unit.
			 
			 At present, this class only support MBCS string and UTF-8/UTF-7 string just as IE's behavior.
			 FireFox also support:
			 UTF-16 (Big Endian and Little Endian), UTF-32 (Big Endian and Little Endian)

			 How CStringA treat the length of encoded char stream if MBCS defined? 
			 Call _mbslen() or _mbslen_l()????
			 
			 
*****************************************************************************/
#ifndef __CURLENCDEC_H_
#define __CURLENCDEC_H_

#include "stdafx.h"

// Does it need to support wide char string input?????

namespace System
{
	namespace Internet
	{

		class CURLEncDec
		{
		private:
			static CStringA csUnsafeString;	// URL encoding operating on bytes stream
			static CStringA DecToHex(const char num, int radix); // URL encoding operating on bytes stream
			static bool IsUnsafe(const char compareChar);
			static CStringA Convert(const char val); // URL encoding operating on bytes stream

			// helper to convert %XX to chars
			static char Hex2Ch (const char* pszHex);

			// can't construct a object
			CURLEncDec() { };
			virtual ~CURLEncDec() { };

		public:
			// Those need URL encoding string must either MBCS or UTF-8 char stream, and encoded result must be a ascii char stream
			static CStringA URLEncode(const char* lpszCharStream); 
			static CStringA URLDecode(const char* lpszCharStream);
		};

	};
};
#endif //__CURLENCODE_H_

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions