/************************************************************************/
/*  Copyright (C), 2016-2020, [IT], ��������Ȩ��;
/*  ģ �� ��������ģ�飬δ�������Ż�;
/*  ��    ����;
/*
/*  ��    ����[V];	
/*  ��    �ߣ�[IT];
/*  ��    �ڣ�[7/26/2016];
/*
/*
/*  ע    �⣺;
/*
/*  �޸ļ�¼��[IT];
/*  �޸����ڣ�;
/*  �޸İ汾��;
/*  �޸����ݣ�;
/************************************************************************/
#ifndef __CHAR_ENCODING__
#define __CHAR_ENCODING__

#include <string>
#include <vector>
using namespace std;

#ifndef _UNICODE
typedef string TString;
#else
typedef wstring TString;
#endif

#pragma once


class  CharEncoding
{
public:
	// ���ַ�ת��Ϊ��Ӧ��ASCIIʮ����ֵ;
	static char CharToInt(char ch);
	// �������ַ���ת����ʮ������ֵ;
	static char StrToBin(IN char (&str)[2]);
	static void GB2312ToUTF_8(string& pOut, const char *pText, int pLen);
	// ��ASCII�ַ���ת��UNICODE�ַ���;
	static WCHAR* ASCII2UNICODE(IN LPCCH lpASCIIStr);
	static BOOL   ASCII2UNICODE(IN LPCCH lpASCIIStr, OUT PWCH pUNICODEStr, IN CONST INT& nUNICODEStrLen);
	static BOOL   ASCII2UNICODE(IN LPCCH lpASCIIStr, OUT wstring &strResult);

	// ��UNICODE�ַ���ת��ASCII�ַ���;
	static CHAR* UNICODE2ASCII(IN LPWCH lpUNICODEStr);
	static BOOL  UNICODE2ASCII(IN LPWCH lpUNICODEStr, OUT LPCH pASCIIStr, IN CONST INT& nASCIIStrLen);
	static BOOL  UNICODE2ASCII(IN LPWCH lpUNICODEStr, OUT string &strResult);

	// ��UNICODE�ַ���ת��UFT8�ַ���;
	static CHAR* UNICODE2UTF8(IN LPWCH lpUNICODEStr);
	static BOOL  UNICODE2UTF8(IN LPWCH lpUNICODEStr, OUT LPCH pUTF8Str, IN CONST INT& nUTF8StrLen);
	static BOOL  UNICODE2UTF8(IN LPWCH lpUNICODEStr, OUT string &strResult);

	// ��ASCII�ַ���ת��UTF8�ַ���;
	static CHAR* ASCII2UTF8(IN LPCCH lpASCIIStr);
	static BOOL  ASCII2UTF8(IN LPCCH lpASCIIStr, OUT LPCH pUTF8Str, IN CONST INT& nUTF8StrLen);
	static BOOL  ASCII2UTF8(IN LPCCH lpASCIIStr, OUT string &strResult);

	// ��UTF-8�ַ���ת��UNICODE�ַ���;
	static WCHAR* UTF82UNICODE(IN LPCCH lpUTF8);
	static BOOL   UTF82UNICODE(IN LPCCH lpUTF8, OUT PWCH pUNICODEStr, IN CONST INT& nUNICODEStrLen);
	static BOOL   UTF82UNICODE(IN LPCCH lpUTF8, OUT wstring &strResult);

	// ��UTF-8�ַ���ת��ASCII�ַ���;
	static CHAR*  UTF82ASCII(IN LPCCH lpUTF8);
	static BOOL   UTF82ASCII(IN LPCCH lpUTF8, OUT LPCH pASCIIStr, IN CONST INT& nASCIIStrLen);
	static BOOL   UTF82ASCII(IN LPCCH lpUTF8, OUT string &strResult);

	// ��UTF-8�����GB2312;
	static string UTF8IntoGB2313(IN CHAR* pUTF8Text, IN const INT& nUTF8TextLen);
	// ��GB2312�����UTF-8;
	static string GB2312IntoUTF8(IN CHAR* pGB2312Text, IN const INT& nGB2312TextLen);

	// ���ַ��������ΪGB2312�����ʽ��URL;
	static string EnCode_GB2312URL(IN CHAR* pText);
	static void EnCode_GB2312URL(IN CHAR* pText, OUT string& strResult);
	// ���ַ��������ΪUTF-8�����ʽ��URL;
	static string EnCode_UTF8URL(IN const CHAR* pText);
	static void EnCode_UTF8URL(IN const CHAR* pText, OUT string& strResult);
	// ���ַ��������ΪUNICODE�����ʽ��URL;
	static string EnCode_UNICODEURL(IN const CHAR* pText);	// δ��ɸú���;

	// ����UTF-8�����ʽ��URL;
	static string DeCode_URLUTF8(IN const CHAR* pURLText);
	static void DeCode_URLUTF8(IN const CHAR* pURLText, OUT string& strResult);
	// ����GB2312�����ʽ��URL;
	static string DeCode_URLGB2312(IN const CHAR* pURLText);
	static void DeCode_URLGB2312(IN const CHAR* pURLText, OUT string& strResult);
	// ����UNICODE�����ʽ��URL;
	static string DeCode_URLUNICODE(IN const CHAR* pURLText);
	static void DeCode_URLUNICODE(IN const CHAR* pURLText, OUT string& strResult);
};

#endif