iconvtest.cpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // iconvtest.cpp : 定义应用程序的类行为。
  2. //
  3. #include "stdafx.h"
  4. #include "iconvtest.h"
  5. #include "iconvtestDlg.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #endif
  9. // CiconvtestApp
  10. BEGIN_MESSAGE_MAP(CiconvtestApp, CWinAppEx)
  11. ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
  12. END_MESSAGE_MAP()
  13. // CiconvtestApp 构造
  14. CiconvtestApp::CiconvtestApp()
  15. {
  16. // TODO: 在此处添加构造代码,
  17. // 将所有重要的初始化放置在 InitInstance 中
  18. }
  19. // 唯一的一个 CiconvtestApp 对象
  20. CiconvtestApp theApp;
  21. // CiconvtestApp 初始化
  22. BOOL CiconvtestApp::InitInstance()
  23. {
  24. // 如果一个运行在 Windows XP 上的应用程序清单指定要
  25. // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
  26. //则需要 InitCommonControlsEx()。否则,将无法创建窗口。
  27. INITCOMMONCONTROLSEX InitCtrls;
  28. InitCtrls.dwSize = sizeof(InitCtrls);
  29. // 将它设置为包括所有要在应用程序中使用的
  30. // 公共控件类。
  31. InitCtrls.dwICC = ICC_WIN95_CLASSES;
  32. InitCommonControlsEx(&InitCtrls);
  33. CWinAppEx::InitInstance();
  34. AfxEnableControlContainer();
  35. // 标准初始化
  36. // 如果未使用这些功能并希望减小
  37. // 最终可执行文件的大小,则应移除下列
  38. // 不需要的特定初始化例程
  39. // 更改用于存储设置的注册表项
  40. // TODO: 应适当修改该字符串,
  41. // 例如修改为公司或组织名
  42. SetRegistryKey(_T("应用程序向导生成的本地应用程序"));
  43. std::string str = "CloudServerDB\\(CloudServerDB)2017年12月31日21时30分16秒.bak";
  44. #if 0 // gbk转utf-8;
  45. //std::string str = "测试Test Sourcedfafdafd在夺苦苦乳白色苦基材苦甘苦圩玩玩圩牺牲";
  46. str = convert("GBK", "utf-8", str.c_str(), str.size());
  47. str = EncodingConverion::UTF82ASCII(str.c_str());
  48. str = EncodingConverion::ASCII2UTF8(str.c_str());
  49. str = convert("utf-8", "GBK", str.c_str(), str.size());
  50. #endif
  51. #if 0//gbk转unicode;
  52. str = "测试Test Sourcedfafdafd在夺苦苦乳白色苦基材苦甘苦圩玩玩圩牺牲";
  53. // UCS-2LE代表unicode小端模式;
  54. str = convert("gb2312", "UCS-2LE", str.c_str(), str.size());
  55. str = convert("UCS-2LE", "gb2312", str.c_str(), str.size());
  56. str = EncodingConverion::UNICODE2ASCII((wchar_t*)str.c_str());
  57. str = "测试Test Sourcedfafdafd在夺苦苦乳白色苦基材苦甘苦圩玩玩圩牺牲";
  58. wchar_t* p = EncodingConverion::ASCII2UNICODE(str.c_str());
  59. str = convert("UCS-2LE", "gb2312", (char*)p, wcslen(p) * 2);
  60. #endif
  61. #if 1
  62. std::string utf8 = convertEx("GBK", "UTF-8", str.c_str(), str.size());
  63. str = convertEx("UTF-8", "GBK", utf8.c_str(), utf8.size());
  64. str = EncodingConverion::UTF82ASCII(utf8.c_str());
  65. #endif
  66. CiconvtestDlg dlg;
  67. m_pMainWnd = &dlg;
  68. INT_PTR nResponse = dlg.DoModal();
  69. if (nResponse == IDOK)
  70. {
  71. // TODO: 在此放置处理何时用
  72. // “确定”来关闭对话框的代码
  73. }
  74. else if (nResponse == IDCANCEL)
  75. {
  76. // TODO: 在此放置处理何时用
  77. // “取消”来关闭对话框的代码
  78. }
  79. // 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序,
  80. // 而不是启动应用程序的消息泵。
  81. return FALSE;
  82. }