StringProcess.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #ifndef __STRING_PROCESS_20151214__
  2. #define __STRING_PROCESS_20151214__
  3. #pragma once
  4. #include <string.h>
  5. #include <vector>
  6. using namespace std;
  7. namespace StringProcess
  8. {
  9. //////////////////////////////////////////////////////////////////////////
  10. // 将utf8字符串转为unicode字符串;
  11. extern WCHAR* utf8_to_unicode(IN const CHAR* pszutf8);
  12. extern INT utf8_to_unicode(IN const CHAR *pszutf8, OUT WCHAR *pszunicode);
  13. // 将utf8字符串转为ascii字符串;
  14. extern CHAR* utf8_to_ascii(IN const CHAR *pszutf8);
  15. extern int utf8_to_ascii(IN const CHAR *pszutf8,OUT CHAR* pszacsii);
  16. // 将unicode字符串转为acsii(gb312)字符串;
  17. extern CHAR* unicode_to_ascii(IN const WCHAR *pszunicode);
  18. extern int unicode_to_ascii(IN const WCHAR *pszunicode, OUT CHAR *pszacsii);
  19. // 将unicode字符串转为utf8字符串;
  20. extern CHAR* unicode_to_uft8(IN const WCHAR *pszunicode);
  21. extern int unicode_to_uft8(IN const WCHAR *pszunicode,OUT CHAR* pszutf8);
  22. // 将ascii字符串转为unicode字符串;
  23. extern WCHAR* ascii_to_unicode(IN const CHAR* pszascii);
  24. extern int ascii_to_unicode(IN const CHAR* pszascii,OUT WCHAR *pszunicode);
  25. // 将ascii字符串转为utf8字符串;
  26. extern CHAR* ascii_to_utf8(IN const CHAR* pszascii);
  27. extern int ascii_to_utf8(IN const CHAR* pszascii, OUT CHAR* pszutf8);
  28. // http使用;
  29. extern void UTF_8ToGB2312(string &pOut, char *pText, int pLen);//utf_8转为gb2312
  30. extern void GB2312ToUTF_8(string& pOut, char *pText, int pLen); //gb2312 转utf_8
  31. extern string UrlGB2312(char * str); //urlgb2312编码
  32. extern string UrlUTF8(char * str); //urlutf8 编码
  33. extern string UrlUTF8Decode(string str); //urlutf8解码
  34. extern string UrlGB2312Decode(string str); //urlgb2312解码
  35. // 下6函数为上6函数的私有函数;
  36. extern void Gb2312ToUnicode(WCHAR* pOut, char *gbBuffer);
  37. extern void UTF_8ToUnicode(WCHAR* pOut, char *pText);
  38. extern void UnicodeToUTF_8(char* pOut, WCHAR* pText);
  39. extern void UnicodeToGB2312(char* pOut, WCHAR uData);
  40. extern char CharToInt(char ch);
  41. extern char StrToBin(char *str);
  42. };
  43. #endif