EncodingConversion.h 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /************************************************************************/
  2. /* Copyright (C), 2016-2020, [IT], 保留所有权利;
  3. /* 模 块 名:;
  4. /* 描 述:;
  5. /*
  6. /* 版 本:[V];
  7. /* 作 者:[IT];
  8. /* 日 期:[12/19/2016];
  9. /*
  10. /*
  11. /* 注 意:;
  12. /*
  13. /* 修改记录:[IT];
  14. /* 修改日期:;
  15. /* 修改版本:;
  16. /* 修改内容:;
  17. /************************************************************************/
  18. #ifndef __ENCODING_CONVERSION__
  19. #define __ENCODING_CONVERSION__
  20. #include <string>
  21. #include <vector>
  22. using namespace std;
  23. #ifndef _UNICODE
  24. typedef string TString;
  25. #else
  26. typedef wstring TString;
  27. #endif
  28. #pragma once
  29. namespace EncodingConverion
  30. {
  31. // 将字符转化为对应的ASCII十进制值;
  32. extern char CharToInt(char ch);
  33. // 将两个字符串转化成十六进制值;
  34. extern char StrToBin(IN char (&str)[2]);
  35. extern void GB2312ToUTF_8(string& pOut, const char *pText, int pLen);
  36. // 将ASCII字符串转成UNICODE字符串;
  37. extern WCHAR* ASCII2UNICODE(IN LPCCH lpASCIIStr);
  38. extern BOOL ASCII2UNICODE(IN LPCCH lpASCIIStr, OUT PWCH pUNICODEStr, IN CONST INT& nUNICODEStrLen);
  39. extern BOOL ASCII2UNICODE(IN LPCCH lpASCIIStr, OUT wstring &strResult);
  40. // 将UNICODE字符串转成ASCII字符串;
  41. extern CHAR* UNICODE2ASCII(IN LPWCH lpUNICODEStr);
  42. extern BOOL UNICODE2ASCII(IN LPWCH lpUNICODEStr, OUT LPCH pASCIIStr, IN CONST INT& nASCIIStrLen);
  43. extern BOOL UNICODE2ASCII(IN LPWCH lpUNICODEStr, OUT string &strResult);
  44. // 将UNICODE字符串转成UFT8字符串;
  45. extern CHAR* UNICODE2UTF8(IN LPWCH lpUNICODEStr);
  46. extern BOOL UNICODE2UTF8(IN LPWCH lpUNICODEStr, OUT LPCH pUTF8Str, IN CONST INT& nUTF8StrLen);
  47. extern BOOL UNICODE2UTF8(IN LPWCH lpUNICODEStr, OUT string &strResult);
  48. // 将ASCII字符串转成UTF8字符串;
  49. extern CHAR* ASCII2UTF8(IN LPCCH lpASCIIStr);
  50. extern BOOL ASCII2UTF8(IN LPCCH lpASCIIStr, OUT LPCH pUTF8Str, IN CONST INT& nUTF8StrLen);
  51. extern BOOL ASCII2UTF8(IN LPCCH lpASCIIStr, OUT string &strResult);
  52. // 将UTF-8字符串转成UNICODE字符串;
  53. extern WCHAR* UTF82UNICODE(IN LPCCH lpUTF8);
  54. extern BOOL UTF82UNICODE(IN LPCCH lpUTF8, OUT PWCH pUNICODEStr, IN CONST INT& nUNICODEStrLen);
  55. extern BOOL UTF82UNICODE(IN LPCCH lpUTF8, OUT wstring &strResult);
  56. // 将UTF-8字符串转成ASCII字符串;
  57. extern CHAR* UTF82ASCII(IN LPCCH lpUTF8);
  58. extern BOOL UTF82ASCII(IN LPCCH lpUTF8, OUT LPCH pASCIIStr, IN CONST INT& nASCIIStrLen);
  59. extern BOOL UTF82ASCII(IN LPCCH lpUTF8, OUT string &strResult);
  60. // 将UTF-8编码成GB2312;
  61. extern string UTF8IntoGB2313(IN CHAR* pUTF8Text, IN const INT& nUTF8TextLen);
  62. // 将GB2312编码成UTF-8;
  63. extern string GB2312IntoUTF8(IN CHAR* pGB2312Text, IN const INT& nGB2312TextLen);
  64. // 将字符串编码成为GB2312编码格式的URL;
  65. extern string EnCode_GB2312URL(IN CHAR* pText);
  66. extern void EnCode_GB2312URL(IN CHAR* pText, OUT string& strResult);
  67. // 将字符串编码成为UTF-8编码格式的URL;
  68. extern string EnCode_UTF8URL(IN const CHAR* pText);
  69. extern void EnCode_UTF8URL(IN const CHAR* pText, OUT string& strResult);
  70. // 将字符串编码成为UNICODE编码格式的URL;
  71. extern string EnCode_UNICODEURL(IN const CHAR* pText); // 未完成该函数;
  72. // 解码UTF-8编码格式的URL;
  73. extern string DeCode_URLUTF8(IN const CHAR* pURLText);
  74. extern void DeCode_URLUTF8(IN const CHAR* pURLText, OUT string& strResult);
  75. // 解码GB2312编码格式的URL;
  76. extern string DeCode_URLGB2312(IN const CHAR* pURLText);
  77. extern void DeCode_URLGB2312(IN const CHAR* pURLText, OUT string& strResult);
  78. // 解码UNICODE编码格式的URL;
  79. extern string DeCode_URLUNICODE(IN const CHAR* pURLText);
  80. extern void DeCode_URLUNICODE(IN const CHAR* pURLText, OUT string& strResult);
  81. };
  82. #endif