// iconvtest.cpp : 定义应用程序的类行为。 // #include "stdafx.h" #include "iconvtest.h" #include "iconvtestDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // CiconvtestApp BEGIN_MESSAGE_MAP(CiconvtestApp, CWinAppEx) ON_COMMAND(ID_HELP, &CWinApp::OnHelp) END_MESSAGE_MAP() // CiconvtestApp 构造 CiconvtestApp::CiconvtestApp() { // TODO: 在此处添加构造代码, // 将所有重要的初始化放置在 InitInstance 中 } // 唯一的一个 CiconvtestApp 对象 CiconvtestApp theApp; // CiconvtestApp 初始化 BOOL CiconvtestApp::InitInstance() { // 如果一个运行在 Windows XP 上的应用程序清单指定要 // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, //则需要 InitCommonControlsEx()。否则,将无法创建窗口。 INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // 将它设置为包括所有要在应用程序中使用的 // 公共控件类。 InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinAppEx::InitInstance(); AfxEnableControlContainer(); // 标准初始化 // 如果未使用这些功能并希望减小 // 最终可执行文件的大小,则应移除下列 // 不需要的特定初始化例程 // 更改用于存储设置的注册表项 // TODO: 应适当修改该字符串, // 例如修改为公司或组织名 SetRegistryKey(_T("应用程序向导生成的本地应用程序")); std::string str = "CloudServerDB\\(CloudServerDB)2017年12月31日21时30分16秒.bak"; #if 0 // gbk转utf-8; //std::string str = "测试Test Sourcedfafdafd在夺苦苦乳白色苦基材苦甘苦圩玩玩圩牺牲"; str = convert("GBK", "utf-8", str.c_str(), str.size()); str = EncodingConverion::UTF82ASCII(str.c_str()); str = EncodingConverion::ASCII2UTF8(str.c_str()); str = convert("utf-8", "GBK", str.c_str(), str.size()); #endif #if 0//gbk转unicode; str = "测试Test Sourcedfafdafd在夺苦苦乳白色苦基材苦甘苦圩玩玩圩牺牲"; // UCS-2LE代表unicode小端模式; str = convert("gb2312", "UCS-2LE", str.c_str(), str.size()); str = convert("UCS-2LE", "gb2312", str.c_str(), str.size()); str = EncodingConverion::UNICODE2ASCII((wchar_t*)str.c_str()); str = "测试Test Sourcedfafdafd在夺苦苦乳白色苦基材苦甘苦圩玩玩圩牺牲"; wchar_t* p = EncodingConverion::ASCII2UNICODE(str.c_str()); str = convert("UCS-2LE", "gb2312", (char*)p, wcslen(p) * 2); #endif #if 1 std::string utf8 = convertEx("GBK", "UTF-8", str.c_str(), str.size()); str = convertEx("UTF-8", "GBK", utf8.c_str(), utf8.size()); str = EncodingConverion::UTF82ASCII(utf8.c_str()); #endif CiconvtestDlg dlg; m_pMainWnd = &dlg; INT_PTR nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: 在此放置处理何时用 // “确定”来关闭对话框的代码 } else if (nResponse == IDCANCEL) { // TODO: 在此放置处理何时用 // “取消”来关闭对话框的代码 } // 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序, // 而不是启动应用程序的消息泵。 return FALSE; }