/************************************************************************/ /* Copyright (C), 2016-2020, [IT], 保留所有权利; /* 模 块 名:; /* 描 述:; /* /* 版 本:[V]; /* 作 者:[IT]; /* 日 期:[12/19/2016]; /* /* /* 注 意:; /* /* 修改记录:[IT]; /* 修改日期:; /* 修改版本:; /* 修改内容:; /************************************************************************/ #ifndef __ENCODING_CONVERSION__ #define __ENCODING_CONVERSION__ #include #include using namespace std; #ifndef _UNICODE typedef string TString; #else typedef wstring TString; #endif #pragma once namespace EncodingConverion { // 将字符转化为对应的ASCII十进制值; extern char CharToInt(char ch); // 将两个字符串转化成十六进制值; extern char StrToBin(IN char (&str)[2]); extern void GB2312ToUTF_8(string& pOut, const char *pText, int pLen); // 将ASCII字符串转成UNICODE字符串; extern WCHAR* ASCII2UNICODE(IN LPCCH lpASCIIStr); extern BOOL ASCII2UNICODE(IN LPCCH lpASCIIStr, OUT PWCH pUNICODEStr, IN CONST INT& nUNICODEStrLen); extern BOOL ASCII2UNICODE(IN LPCCH lpASCIIStr, OUT wstring &strResult); // 将UNICODE字符串转成ASCII字符串; extern CHAR* UNICODE2ASCII(IN LPWCH lpUNICODEStr); extern BOOL UNICODE2ASCII(IN LPWCH lpUNICODEStr, OUT LPCH pASCIIStr, IN CONST INT& nASCIIStrLen); extern BOOL UNICODE2ASCII(IN LPWCH lpUNICODEStr, OUT string &strResult); // 将UNICODE字符串转成UFT8字符串; extern CHAR* UNICODE2UTF8(IN LPWCH lpUNICODEStr); extern BOOL UNICODE2UTF8(IN LPWCH lpUNICODEStr, OUT LPCH pUTF8Str, IN CONST INT& nUTF8StrLen); extern BOOL UNICODE2UTF8(IN LPWCH lpUNICODEStr, OUT string &strResult); // 将ASCII字符串转成UTF8字符串; extern CHAR* ASCII2UTF8(IN LPCCH lpASCIIStr); extern BOOL ASCII2UTF8(IN LPCCH lpASCIIStr, OUT LPCH pUTF8Str, IN CONST INT& nUTF8StrLen); extern BOOL ASCII2UTF8(IN LPCCH lpASCIIStr, OUT string &strResult); // 将UTF-8字符串转成UNICODE字符串; extern WCHAR* UTF82UNICODE(IN LPCCH lpUTF8); extern BOOL UTF82UNICODE(IN LPCCH lpUTF8, OUT PWCH pUNICODEStr, IN CONST INT& nUNICODEStrLen); extern BOOL UTF82UNICODE(IN LPCCH lpUTF8, OUT wstring &strResult); // 将UTF-8字符串转成ASCII字符串; extern CHAR* UTF82ASCII(IN LPCCH lpUTF8); extern BOOL UTF82ASCII(IN LPCCH lpUTF8, OUT LPCH pASCIIStr, IN CONST INT& nASCIIStrLen); extern BOOL UTF82ASCII(IN LPCCH lpUTF8, OUT string &strResult); // 将UTF-8编码成GB2312; extern string UTF8IntoGB2313(IN CHAR* pUTF8Text, IN const INT& nUTF8TextLen); // 将GB2312编码成UTF-8; extern string GB2312IntoUTF8(IN CHAR* pGB2312Text, IN const INT& nGB2312TextLen); // 将字符串编码成为GB2312编码格式的URL; extern string EnCode_GB2312URL(IN CHAR* pText); extern void EnCode_GB2312URL(IN CHAR* pText, OUT string& strResult); // 将字符串编码成为UTF-8编码格式的URL; extern string EnCode_UTF8URL(IN const CHAR* pText); extern void EnCode_UTF8URL(IN const CHAR* pText, OUT string& strResult); // 将字符串编码成为UNICODE编码格式的URL; extern string EnCode_UNICODEURL(IN const CHAR* pText); // 未完成该函数; // 解码UTF-8编码格式的URL; extern string DeCode_URLUTF8(IN const CHAR* pURLText); extern void DeCode_URLUTF8(IN const CHAR* pURLText, OUT string& strResult); // 解码GB2312编码格式的URL; extern string DeCode_URLGB2312(IN const CHAR* pURLText); extern void DeCode_URLGB2312(IN const CHAR* pURLText, OUT string& strResult); // 解码UNICODE编码格式的URL; extern string DeCode_URLUNICODE(IN const CHAR* pURLText); extern void DeCode_URLUNICODE(IN const CHAR* pURLText, OUT string& strResult); }; #endif