CharConvert.h 995 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #pragma once
  2. #include "stdafx.h"
  3. #include<string>
  4. using namespace std;
  5. #pragma region 字符串处理
  6. //说明:Unicode转换为ANSI,由于系统语言区域设置原因,目前只支持处理英文内容
  7. class CharConvert
  8. {
  9. #pragma region Unicode和ANSI
  10. public:
  11. /// <summary>
  12. /// 多字节字符转换为宽字符
  13. /// </summary>
  14. static wstring GetWideCharW(char* multiByte);
  15. static wstring GetWideCharW(string* multiByte);
  16. /// <summary>
  17. /// 宽字符转换为多字节字符
  18. /// </summary>
  19. /// <param name="wideChar"></param>
  20. /// <returns></returns>
  21. static char* GetMultiByteW(wchar_t* wideChar);
  22. static char* GetMultiByteW(wstring wideStr);
  23. static char* GetMultiByteUTF8W(wchar_t* wideChar);
  24. static wstring ReplaceSubStrW(wstring sourceStr, const wstring& oldSubStr, const wstring& newSubStr);
  25. #pragma endregion
  26. #pragma region 字符转换
  27. static char* StringTocharPtrA(string* sourceStr);
  28. static wchar_t* wstringToWchar_tPtrW(wstring ws);
  29. static char* GetWstringToCharPtr(wstring ws);
  30. #pragma endregion
  31. };
  32. #pragma endregion