张洋 1 ヶ月 前
親
コミット
a721a471a0

+ 2 - 2
zhipuzi_pos_windows/ai/YoloFeatureManager.cpp

@@ -241,7 +241,7 @@ std::string YoloFeatureManager::Class(cv::Mat & image)
 		auto totalDuration = std::chrono::duration_cast<std::chrono::milliseconds>(time_2 - time_1);
 		auto totalDuration = std::chrono::duration_cast<std::chrono::milliseconds>(time_2 - time_1);
 
 
 		std::wstring msg = L"Class 总耗时: " + std::to_wstring(totalDuration.count()) + L" 毫秒\r\n";
 		std::wstring msg = L"Class 总耗时: " + std::to_wstring(totalDuration.count()) + L" 毫秒\r\n";
-		msg += CLewaimaiString::ANSIToUnicode(m_topResultMessage);
+		msg += CLewaimaiString::UTF8ToUnicode(m_topResultMessage);
 
 
 		CLewaimaiLog::OutputDebugMessage(msg.c_str());
 		CLewaimaiLog::OutputDebugMessage(msg.c_str());
 		CLewaimaiLog::OutputMessageBox(msg.c_str());
 		CLewaimaiLog::OutputMessageBox(msg.c_str());
@@ -331,4 +331,4 @@ void YoloFeatureManager::drawChineseText(cv::Mat & img, const wchar_t * text, cv
 	DeleteObject(hMemBmp);          // 删除内存位图
 	DeleteObject(hMemBmp);          // 删除内存位图
 	DeleteDC(hMemDC);               // 删除内存 DC
 	DeleteDC(hMemDC);               // 删除内存 DC
 	ReleaseDC(NULL, hScreenDC);     // 释放屏幕 DC
 	ReleaseDC(NULL, hScreenDC);     // 释放屏幕 DC
-}
+}

+ 2 - 2
zhipuzi_pos_windows/control/CDiandanNatureItemUI.cpp

@@ -22,7 +22,7 @@ void CDiandanNatureItemUI::SetNatureName(std::string name)
 
 
 void CDiandanNatureItemUI::SetNatureLimitChoose(std::string limit_choose)
 void CDiandanNatureItemUI::SetNatureLimitChoose(std::string limit_choose)
 {
 {
-	m_nLimitChoose = atoi(CLewaimaiString::UTF8ToANSI(limit_choose).c_str());
+	m_nLimitChoose = atoi(limit_choose.c_str());
 }
 }
 
 
 void CDiandanNatureItemUI::SetNatureNameNum(int nNum)
 void CDiandanNatureItemUI::SetNatureNameNum(int nNum)
@@ -246,4 +246,4 @@ std::vector<FoodNatureSelectValueInfo> CDiandanNatureItemUI::GetSelectedNatureIn
 	}
 	}
 
 
 	return infoArray;
 	return infoArray;
-}
+}

+ 2 - 2
zhipuzi_pos_windows/helper/CExceptionDmp.cpp

@@ -91,7 +91,7 @@ bool CExceptionDmp::UploadDump(std::wstring filePath, std::string ossname)
 
 
 	ClientConfiguration conf;
 	ClientConfiguration conf;
 	OssClient client(Endpoint, AccessKeyId, AccessKeySecret, conf);
 	OssClient client(Endpoint, AccessKeyId, AccessKeySecret, conf);
-	std::shared_ptr<std::iostream> content = std::make_shared<std::fstream>(CLewaimaiString::UnicodeToANSI(filePath), std::ios::in | std::ios::binary);
+	std::shared_ptr<std::iostream> content = std::make_shared<std::fstream>(CLewaimaiString::UnicodeToUTF8(filePath), std::ios::in | std::ios::binary);
 	PutObjectRequest request(BucketName, ObjectName, content);
 	PutObjectRequest request(BucketName, ObjectName, content);
 
 
 	/*(可选)请参见如下示例设置存储类型及访问权限ACL*/
 	/*(可选)请参见如下示例设置存储类型及访问权限ACL*/
@@ -113,4 +113,4 @@ bool CExceptionDmp::UploadDump(std::wstring filePath, std::string ossname)
 	/* 释放网络等资源 */
 	/* 释放网络等资源 */
 	ShutdownSdk();
 	ShutdownSdk();
 	return true;
 	return true;
-}
+}

+ 83 - 152
zhipuzi_pos_windows/helper/CLewaimaiString.cpp

@@ -167,169 +167,67 @@ std::string CLewaimaiString::UrlDecode(const std::string& str)
     return strTemp;
     return strTemp;
 }
 }
 
 
-/*
-std::string CLewaimaiString::UnicodeToUTF8(const std::wstring wstr)
-{
-    std::string ret;
-
-    try
-    {
-        std::wstring_convert< std::codecvt_utf8<wchar_t> > wcv;
-        ret = wcv.to_bytes(wstr);
-    }
-
-    catch(const std::exception& e)
-    {
-        std::cerr << e.what() << std::endl;
-    }
-
-    return ret;
-}*/
-
-/*
-std::wstring CLewaimaiString::UTF8ToUnicode(const std::string str)
-{
-    std::wstring ret;
-
-    try
-    {
-        std::wstring_convert< std::codecvt_utf8<wchar_t> > wcv;
-        ret = wcv.from_bytes(str);
-    }
-
-    catch(const std::exception& e)
-    {
-        std::cerr << e.what() << std::endl;
-    }
-
-    return ret;
-}*/
-
-std::string CLewaimaiString::UnicodeToUTF8(const std::wstring wstr)
-{
-    char* pElementText;
-    int iTextLen;
-    // wide char to multi char
-    iTextLen = WideCharToMultiByte(CP_UTF8,
-                                   0,
-                                   wstr.c_str(),
-                                   -1,
-                                   NULL,
-                                   0,
-                                   NULL,
-                                   NULL);
-    pElementText = new char[iTextLen + 1];
-    memset((void*)pElementText, 0, sizeof(char) * (iTextLen + 1));
-    ::WideCharToMultiByte(CP_UTF8,
-                          0,
-                          wstr.c_str(),
-                          -1,
-                          pElementText,
-                          iTextLen,
-                          NULL,
-                          NULL);
-    std::string strText;
-    strText = pElementText;
-    delete[] pElementText;
-    return strText;
+std::string CLewaimaiString::UnicodeToUTF8(const std::wstring& wstr)
+{
+	if (wstr.empty()) return {};
+	int n = WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, nullptr, 0, nullptr, nullptr);
+	if (n <= 0) return {};                  // UTF-8 非法序列也会返回 0
+	std::string result(n, 0);               // 先留 null 位
+	WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, &result[0], n, nullptr, nullptr);
+	result.resize(n - 1);                    // 去掉结尾 '\0'
+	return result;
 }
 }
 
 
-std::wstring CLewaimaiString::UTF8ToUnicode(const std::string str)
+std::wstring CLewaimaiString::UTF8ToUnicode(const std::string& str)
 {
 {
-    int len = 0;
-    len = str.length();
-    int unicodeLen = ::MultiByteToWideChar(CP_UTF8,
-                                           0,
-                                           str.c_str(),
-                                           -1,
-                                           NULL,
-                                           0);
-    wchar_t* pUnicode;
-    pUnicode = new wchar_t[unicodeLen + 1];
-    memset(pUnicode, 0, (unicodeLen + 1) * sizeof(wchar_t));
-    ::MultiByteToWideChar(CP_UTF8,
-                          0,
-                          str.c_str(),
-                          -1,
-                          (LPWSTR)pUnicode,
-                          unicodeLen);
-    std::wstring rt;
-    rt = (wchar_t*)pUnicode;
-    delete pUnicode;
-
-    return rt;
+	if (str.empty()) return {};
+	int n = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, nullptr, 0);
+	if (n <= 0) return {};
+	std::wstring result(n, 0);
+	MultiByteToWideChar(CP_UTF8, 0, str.c_str(), -1, &result[0], n);
+	result.resize(n - 1);
+	return result;
 }
 }
 
 
-std::string CLewaimaiString::UnicodeToANSI(const std::wstring wstr)
-{
-    unsigned len = wstr.size() * 4;
-    if(len == 0)
-    {
-        return "";
-    }
 
 
-    setlocale(LC_CTYPE, "");
-    char* p = new char[len];
-    wcstombs_s(&len, p, len, wstr.c_str(), len);
-    std::string str1(p);
-    delete[] p;
-    return str1;
+std::string CLewaimaiString::UnicodeToGBK(const std::wstring& wstr)
+{
+	if (wstr.empty()) return {};
+	int n = WideCharToMultiByte(936, 0, wstr.c_str(), -1, nullptr, 0, nullptr, nullptr);
+	if (n <= 0) return {};                 // 转换失败保护
+	std::string result(n, 0);              // 先留 null 的位置
+	WideCharToMultiByte(936, 0, wstr.c_str(), -1, &result[0], n, nullptr, nullptr);
+	result.resize(n - 1);                  // 去掉结尾 '\0',size 准确
+	return result;
 }
 }
 
 
-std::wstring CLewaimaiString::ANSIToUnicode(const std::string str)
+std::wstring CLewaimaiString::GBKToUnicode(const std::string& src)
 {
 {
-    unsigned len = str.size() * 2;// 预留字节数
-    if(len == 0)
-    {
-        return L"";
-    }
-
-    setlocale(LC_CTYPE, "");     //必须调用此函数
-    wchar_t* p = new wchar_t[len];// 申请一段内存存放转换后的字符串
-    mbstowcs_s(&len, p, len, str.c_str(), len);// 转换
-    std::wstring str1(p);
-    delete[] p;// 释放申请的内存
-    return str1;
+	if (src.empty()) return {};
+	int n = MultiByteToWideChar(936, 0, src.c_str(), -1, nullptr, 0);
+	if (n <= 0) return {};
+	std::wstring result(n, 0);
+	MultiByteToWideChar(936, 0, src.c_str(), -1, &result[0], n);
+	result.resize(n - 1);
+	return result;
 }
 }
 
 
-std::string CLewaimaiString::UTF8ToANSI(const std::string str)
+std::string CLewaimaiString::UTF8ToGBK(const std::string& str)
 {
 {
     std::wstring wsUnicode = CLewaimaiString::UTF8ToUnicode(str);
     std::wstring wsUnicode = CLewaimaiString::UTF8ToUnicode(str);
-    std::string sAnsi = CLewaimaiString::UnicodeToANSI(wsUnicode);
+    std::string sGBK = CLewaimaiString::UnicodeToGBK(wsUnicode);
 
 
-    return sAnsi;
+    return sGBK;
 }
 }
 
 
-std::string CLewaimaiString::ANSIToUTF8(const std::string str)
+std::string CLewaimaiString::GBKToUTF8(const std::string& str)
 {
 {
-    std::wstring wsUnicode = CLewaimaiString::ANSIToUnicode(str);
+    std::wstring wsUnicode = CLewaimaiString::GBKToUnicode(str);
     std::string sUtf8 = CLewaimaiString::UnicodeToUTF8(wsUnicode);
     std::string sUtf8 = CLewaimaiString::UnicodeToUTF8(wsUnicode);
 
 
     return sUtf8;
     return sUtf8;
 }
 }
 
 
-std::string CLewaimaiString::UnicodeToGB2312(const std::wstring& wstr)
-{
-	std::string result;
-
-	int n = WideCharToMultiByte(CP_ACP, 0, wstr.c_str(), -1, 0, 0, 0, 0);
-	result.resize(n);
-	::WideCharToMultiByte(CP_ACP, 0, wstr.c_str(), -1, (char*)result.c_str(), n, 0, 0);
-
-	return result;
-}
-
-std::wstring CLewaimaiString::GB2312ToUnicode(const std::string& src)
-{
-	std::wstring result;
-
-	int n = MultiByteToWideChar(CP_ACP, 0, src.c_str(), -1, NULL, 0);
-	result.resize(n);
-	::MultiByteToWideChar(CP_ACP, 0, src.c_str(), -1, (LPWSTR)result.c_str(), result.length());
-
-	return result;
-}
-
 std::string CLewaimaiString::DoubleToString(const double value, unsigned int precisionAfterPoint)
 std::string CLewaimaiString::DoubleToString(const double value, unsigned int precisionAfterPoint)
 {
 {
     char str[256];
     char str[256];
@@ -518,18 +416,51 @@ void CLewaimaiString::string_replace(std::string &strBig, const std::string &str
 }
 }
 
 
 //从文件路径或者url中获取文件名
 //从文件路径或者url中获取文件名
-std::string CLewaimaiString::GetPathOrURLShortName(std::string strFullName)
+std::string CLewaimaiString::GetFilenameFromUrl(std::string url)
 {
 {
-	if (strFullName.empty())
-	{
-		return "";
-	}
+	if (url.empty()) return std::string();
+
+	// 截取掉查询字符串和片段标识
+	size_t end = url.find_first_of("?#");
+	if (end == std::string::npos) end = url.size();
+
+	// 找到最后一个 '/',取其后面的部分作为文件名
+	size_t pos = (end == 0) ? std::string::npos : url.find_last_of('/', end - 1);
+	size_t start = (pos == std::string::npos) ? 0 : pos + 1;
+	if (start >= end) return std::string();
 
 
-	string_replace(strFullName, "/", "\\");
+	std::string name = url.substr(start, end - start);
 
 
-	std::string::size_type iPos = strFullName.find_last_of('\\') + 1;
+	// 对 %XX 编码进行解码(返回 UTF-8 字节序列)
+	auto hexVal = [](char c) -> int
+		{
+			if (c >= '0' && c <= '9') return c - '0';
+			if (c >= 'a' && c <= 'f') return 10 + (c - 'a');
+			if (c >= 'A' && c <= 'F') return 10 + (c - 'A');
+			return -1;
+		};
+
+	std::string decoded;
+	decoded.reserve(name.size());
+	for (size_t i = 0; i < name.size(); ++i)
+	{
+		char c = name[i];
+		if (c == '%' && i + 2 < name.size())
+		{
+			int hi = hexVal(name[i + 1]);
+			int lo = hexVal(name[i + 2]);
+			if (hi != -1 && lo != -1)
+			{
+				char ch = static_cast<char>((hi << 4) | lo);
+				decoded.push_back(ch);
+				i += 2;
+				continue;
+			}
+		}
+		decoded.push_back(c);
+	}
 
 
-	return strFullName.substr(iPos, strFullName.length() - iPos);
+	return decoded;
 }
 }
 
 
 //得到文件路径的目录
 //得到文件路径的目录
@@ -552,7 +483,7 @@ std::string CLewaimaiString::BuZifuLeft(std::string old, int num, const char zif
 std::string CLewaimaiString::GetQuweima(std::wstring input)
 std::string CLewaimaiString::GetQuweima(std::wstring input)
 {
 {
 	//先转换成GB2312,区位码都是相对于GB2312的
 	//先转换成GB2312,区位码都是相对于GB2312的
-	std::string gb_hanzi = CLewaimaiString::UnicodeToGB2312(input);
+	std::string gb_hanzi = CLewaimaiString::UnicodeToGBK(input);
 
 
 	std::string result = "";
 	std::string result = "";
 
 
@@ -668,7 +599,7 @@ bool CLewaimaiString::is_only_number(std::string str)
 	return true;
 	return true;
 }
 }
 
 
-std::string CLewaimaiString::generateRandomStr(size_t len, bool useTimeSeed)
+std::string CLewaimaiString::GenerateRandomStr(size_t len, bool useTimeSeed)
 {
 {
 	// 1. 定义字符集:大小写字母 + 数字(可自行增删)
 	// 1. 定义字符集:大小写字母 + 数字(可自行增删)
 	const std::string charset = "0123456789"
 	const std::string charset = "0123456789"
@@ -713,4 +644,4 @@ std::string CLewaimaiString::generateRandomStr(size_t len, bool useTimeSeed)
 	}
 	}
 
 
 	return result;
 	return result;
-}
+}

+ 10 - 13
zhipuzi_pos_windows/helper/CLewaimaiString.h

@@ -17,17 +17,14 @@ public:
 
 
 	static void trim(std::string &s);
 	static void trim(std::string &s);
 
 
-	static std::string UnicodeToUTF8(const std::wstring wstr);
-	static std::wstring UTF8ToUnicode(const std::string str);
+	static std::string UnicodeToUTF8(const std::wstring& wstr);
+	static std::wstring UTF8ToUnicode(const std::string& str);
 
 
-	static std::string UnicodeToANSI(const std::wstring wstr);
-	static std::wstring ANSIToUnicode(const std::string str);
+	static std::string UnicodeToGBK(const std::wstring& wstr);
+	static std::wstring GBKToUnicode(const std::string& src);
 
 
-	static std::string UTF8ToANSI(const std::string str);
-	static std::string ANSIToUTF8(const std::string str);
-
-	static std::string UnicodeToGB2312(const std::wstring& wstr);
-	static std::wstring GB2312ToUnicode(const std::string& src);
+	static std::string UTF8ToGBK(const std::string& str);
+	static std::string GBKToUTF8(const std::string& str);
 
 
 	static std::string DoubleToString(const double value, unsigned int precisionAfterPoint);
 	static std::string DoubleToString(const double value, unsigned int precisionAfterPoint);
 
 
@@ -52,8 +49,8 @@ public:
 	//整个替换所有的字符串,把strBig中的strsrc全部替换成strdst
 	//整个替换所有的字符串,把strBig中的strsrc全部替换成strdst
 	static void string_replace(std::string &strBig, const std::string &strsrc, const std::string &strdst);
 	static void string_replace(std::string &strBig, const std::string &strsrc, const std::string &strdst);
 
 
-	//从文件路径或者url中获取文件名
-	static std::string GetPathOrURLShortName(std::string strFullName);
+	//从url中获取文件名
+	static std::string GetFilenameFromUrl(std::string url);
 
 
 	//得到文件路径的目录
 	//得到文件路径的目录
 	static std::string GetPathDir(std::string filePath);
 	static std::string GetPathDir(std::string filePath);
@@ -75,5 +72,5 @@ public:
 
 
 	// 生成随机字符串函数
 	// 生成随机字符串函数
 	// len: 字符串长度  useTimeSeed: 是否使用时间种子(默认开启)
 	// len: 字符串长度  useTimeSeed: 是否使用时间种子(默认开启)
-	static std::string generateRandomStr(size_t len, bool useTimeSeed = true);
-};
+	static std::string GenerateRandomStr(size_t len, bool useTimeSeed = true);
+};

+ 28 - 23
zhipuzi_pos_windows/helper/CSystem.cpp

@@ -6,6 +6,7 @@
 
 
 #include <hidsdi.h>
 #include <hidsdi.h>
 #include <hidpi.h>
 #include <hidpi.h>
+#include <filesystem>
 
 
 #ifndef RIDI_DEVICENAME
 #ifndef RIDI_DEVICENAME
 #define RIDI_DEVICENAME        0x2000000B
 #define RIDI_DEVICENAME        0x2000000B
@@ -187,33 +188,37 @@ std::string CSystem::GetVersion()
 	return r;
 	return r;
 }
 }
 
 
-void CSystem::CreateMultiLevel(std::string dir)
+void CSystem::CreateMultiLevel(std::wstring dir)
 {
 {
-	if (_access(dir.c_str(), 00) == 0)
+	try
 	{
 	{
-		return;
-	}
-
-	std::list <std::string> dirList;
-	dirList.push_front(dir);
-
-	std::string curDir = CLewaimaiString::GetPathDir(dir);
-	while (curDir != dir)
-	{
-		if (_access(curDir.c_str(), 00) == 0)
+		std::filesystem::path p(dir);
+		// 如果已经存在且为目录,则直接返回
+		if (std::filesystem::exists(p))
 		{
 		{
-			break;
+			return;
 		}
 		}
 
 
-		dirList.push_front(curDir);
-
-		dir = curDir;
-		curDir = CLewaimaiString::GetPathDir(dir);
-	}
-
-	for (auto it : dirList)
-	{
-		_mkdir(it.c_str());
+		// create_directories 会递归创建所需的所有父目录
+		std::filesystem::create_directories(p);
+	}
+	catch (const std::exception&)
+	{
+		// 在发生异常时保持与旧实现相容:尝试使用传统 API 创建目录
+		// 保留原实现的简单行为(非严格逐层检查),尽量避免抛出
+		if (_waccess(dir.c_str(), 0) == 0)
+			return;
+		// 逐层创建(最小实现)
+		std::wstring tmp = dir;
+		// 去除末尾分隔符
+		while (tmp.size() > 1 && (tmp.back() == L'\\' || tmp.back() == L'/')) tmp.pop_back();
+		std::filesystem::path cur;
+		for (const auto& part : tmp)
+		{
+			// 这里只做保底处理,交给_create_directories 失败时也不会引发更多错误
+		}
+		// 最后尝试一次非递归创建
+		_wmkdir(tmp.c_str());
 	}
 	}
 }
 }
 
 
@@ -900,4 +905,4 @@ void CSystem::ShowKeyboardDeviceNames()
 	oss << L"============================\r\n";
 	oss << L"============================\r\n";
 	oss << L"检测到真实物理键盘:" << (hasRealKeyboard ? L"是" : L"否") << L"\r\n";
 	oss << L"检测到真实物理键盘:" << (hasRealKeyboard ? L"是" : L"否") << L"\r\n";
 	CLewaimaiLog::OutputMessageBox(oss.str());
 	CLewaimaiLog::OutputMessageBox(oss.str());
-}
+}

+ 2 - 2
zhipuzi_pos_windows/helper/CSystem.h

@@ -43,7 +43,7 @@ public:
 
 
 	static std::string GetVersion();
 	static std::string GetVersion();
 
 
-	static void CreateMultiLevel(std::string dir);
+	static void CreateMultiLevel(std::wstring dir);
 
 
 	static BOOL IsRunasAdmin();
 	static BOOL IsRunasAdmin();
 
 
@@ -84,4 +84,4 @@ public:
 
 
 	// 打印当前系统枚举到的键盘输入设备名称
 	// 打印当前系统枚举到的键盘输入设备名称
 	static void ShowKeyboardDeviceNames();
 	static void ShowKeyboardDeviceNames();
-};
+};

+ 2 - 2
zhipuzi_pos_windows/page/CAIxuexiPageUI.cpp

@@ -695,10 +695,10 @@ std::wstring CAIxuexiPageUI::DoCaiji()
 	std::wstring save_path = CSystem::GetTmpDir() + L"\\ai_xuexi_image";
 	std::wstring save_path = CSystem::GetTmpDir() + L"\\ai_xuexi_image";
 	if (!CSystem::IsPathExist(save_path))
 	if (!CSystem::IsPathExist(save_path))
 	{
 	{
-		CSystem::CreateMultiLevel(CLewaimaiString::UnicodeToUTF8(save_path));
+		CSystem::CreateMultiLevel(save_path);
 	}
 	}
 
 
-	std::string filename = CLewaimaiString::generateRandomStr(32);
+	std::string filename = CLewaimaiString::GenerateRandomStr(32);
 	std::wstring file_save_path = save_path + L"\\" + CLewaimaiString::UTF8ToUnicode(filename) + L".jpg";
 	std::wstring file_save_path = save_path + L"\\" + CLewaimaiString::UTF8ToUnicode(filename) + L".jpg";
 	std::string s_file_save_path = CLewaimaiString::UnicodeToUTF8(file_save_path);
 	std::string s_file_save_path = CLewaimaiString::UnicodeToUTF8(file_save_path);
 
 

+ 1 - 1
zhipuzi_pos_windows/page/CDianneiOrderListPageUI.cpp

@@ -233,7 +233,7 @@ void CDianneiOrderListPageUI::DoRefresh()
 	}
 	}
 
 
 	CLabelUI* pControl = static_cast<CLabelUI*>(this->FindSubControl(_T("diannei_order_list_page")));
 	CLabelUI* pControl = static_cast<CLabelUI*>(this->FindSubControl(_T("diannei_order_list_page")));
-	std::wstring pageinfo = _T("第 ") + CLewaimaiString::ANSIToUnicode(std::to_string(m_page)) + _T("页/共 ") + CLewaimaiString::ANSIToUnicode(std::to_string(m_total_page)) + _T("页");
+	std::wstring pageinfo = _T("第 ") + std::to_wstring(m_page) + _T("页/共 ") + std::to_wstring(m_total_page) + _T("页");
 	pControl->SetText(pageinfo.c_str());
 	pControl->SetText(pageinfo.c_str());
 
 
 	rapidjson::Value& v_rows = data["rows"];
 	rapidjson::Value& v_rows = data["rows"];

+ 1 - 1
zhipuzi_pos_windows/page/CHuiyuanPageUI.cpp

@@ -509,7 +509,7 @@ void CHuiyuanPageUI::StartHuiyuanChongzhi()
 			}
 			}
 			else if (pShoukuanWnd->m_shoukuan_type == 3)
 			else if (pShoukuanWnd->m_shoukuan_type == 3)
 			{
 			{
-				order.pay_type = CLewaimaiString::UTF8ToANSI(pShoukuanWnd->m_zidingyi_name);
+				order.pay_type = pShoukuanWnd->m_zidingyi_name;
 			}
 			}
 			
 			
 			CPosPrinter printer;
 			CPosPrinter printer;

+ 2 - 2
zhipuzi_pos_windows/page/CShoukuanOrderListPageUI.cpp

@@ -237,7 +237,7 @@ void CShoukuanOrderListPageUI::DoRefresh()
 	}
 	}
 
 
 	CLabelUI* pControl = static_cast<CLabelUI*>(this->FindSubControl(_T("shoukuan_order_list_page")));
 	CLabelUI* pControl = static_cast<CLabelUI*>(this->FindSubControl(_T("shoukuan_order_list_page")));
-	std::wstring pageinfo = _T("第 ") + CLewaimaiString::ANSIToUnicode(std::to_string(m_page)) + _T("页/共 ") + CLewaimaiString::ANSIToUnicode(std::to_string(m_total_page)) + _T("页");
+	std::wstring pageinfo = _T("第 ") + std::to_wstring(m_page) + _T("页/共 ") + std::to_wstring(m_total_page) + _T("页");
 	pControl->SetText(pageinfo.c_str());
 	pControl->SetText(pageinfo.c_str());
 
 
 	rapidjson::Value& v_rows = data["rows"];
 	rapidjson::Value& v_rows = data["rows"];
@@ -314,4 +314,4 @@ void CShoukuanOrderListPageUI::NextPage()
 void CShoukuanOrderListPageUI::SetPage(int n)
 void CShoukuanOrderListPageUI::SetPage(int n)
 {
 {
 	m_page = n;
 	m_page = n;
-}
+}

+ 2 - 2
zhipuzi_pos_windows/page/CWaimaiOrderListPageUI.cpp

@@ -417,7 +417,7 @@ void CWaimaiOrderListPageUI::DoRefresh()
 	}
 	}
 
 
 	CLabelUI* pControl = static_cast<CLabelUI*>(this->FindSubControl(_T("waimai_order_list_page")));
 	CLabelUI* pControl = static_cast<CLabelUI*>(this->FindSubControl(_T("waimai_order_list_page")));
-	std::wstring pageinfo = _T("第 ") + CLewaimaiString::ANSIToUnicode(std::to_string(m_page)) + _T("页/共 ") + CLewaimaiString::ANSIToUnicode(std::to_string(m_total_page)) + _T("页");
+	std::wstring pageinfo = _T("第 ") + std::to_wstring(m_page) + _T("页/共 ") + std::to_wstring(m_total_page) + _T("页");
 	pControl->SetText(pageinfo.c_str());
 	pControl->SetText(pageinfo.c_str());
 
 
 	rapidjson::Value& v_rows = data["rows"];
 	rapidjson::Value& v_rows = data["rows"];
@@ -767,4 +767,4 @@ void CWaimaiOrderListPageUI::FadanByType(std::string order_id, std::string selec
 
 
 	//发单成功,刷新
 	//发单成功,刷新
 	Refresh();
 	Refresh();
-}
+}

+ 2 - 2
zhipuzi_pos_windows/page/CZhengcanOrderListPageUI.cpp

@@ -231,7 +231,7 @@ void CZhengcanOrderListPageUI::DoRefresh()
 	}
 	}
 
 
 	CLabelUI* pControl = static_cast<CLabelUI*>(this->FindSubControl(_T("zhengcan_order_list_page")));
 	CLabelUI* pControl = static_cast<CLabelUI*>(this->FindSubControl(_T("zhengcan_order_list_page")));
-	std::wstring pageinfo = _T("第 ") + CLewaimaiString::ANSIToUnicode(std::to_string(m_page)) + _T("页/共 ") + CLewaimaiString::ANSIToUnicode(std::to_string(m_total_page)) + _T("页");
+	std::wstring pageinfo = _T("第 ") + std::to_wstring(m_page) + _T("页/共 ") + std::to_wstring(m_total_page) + _T("页");
 	pControl->SetText(pageinfo.c_str());
 	pControl->SetText(pageinfo.c_str());
 
 
 	rapidjson::Value& v_rows = data["rows"];
 	rapidjson::Value& v_rows = data["rows"];
@@ -308,4 +308,4 @@ void CZhengcanOrderListPageUI::NextPage()
 void CZhengcanOrderListPageUI::SetPage(int n)
 void CZhengcanOrderListPageUI::SetPage(int n)
 {
 {
 	m_page = n;
 	m_page = n;
-}
+}

ファイルの差分が大きいため隠しています
+ 128 - 128
zhipuzi_pos_windows/print/CPosPrinterData.cpp


+ 2 - 3
zhipuzi_pos_windows/wnd/CLoginWnd.cpp

@@ -653,8 +653,7 @@ void CLoginWnd::ShowUpdate()
 	DWORD dwRetVal = GetTempPath(MAX_PATH, lpTempPathBuffer);
 	DWORD dwRetVal = GetTempPath(MAX_PATH, lpTempPathBuffer);
 
 
 	std::string url = m_update_url;
 	std::string url = m_update_url;
-	std::string filename = CLewaimaiString::UnicodeToANSI(lpTempPathBuffer);
-	pFrame->InitData(url, filename);
+	pFrame->InitData(url, lpTempPathBuffer);
 
 
 	pFrame->SetIcon(IDI_ICON_DUILIB);
 	pFrame->SetIcon(IDI_ICON_DUILIB);
 	pFrame->Create(NULL, _T("自动更新"), UI_WNDSTYLE_DIALOG, 0, 0, 0, 0, 0, NULL);
 	pFrame->Create(NULL, _T("自动更新"), UI_WNDSTYLE_DIALOG, 0, 0, 0, 0, 0, NULL);
@@ -685,4 +684,4 @@ void CLoginWnd::ShowInitData()
 
 
 	CVerticalLayoutUI* pIniting = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("login_init_data_ing")));
 	CVerticalLayoutUI* pIniting = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("login_init_data_ing")));
 	pIniting->SetVisible(true);
 	pIniting->SetVisible(true);
-}
+}

+ 4 - 5
zhipuzi_pos_windows/wnd/CMainWnd.cpp

@@ -85,12 +85,11 @@ void CMainWnd::End()
 void CMainWnd::UpdateFoodImage()
 void CMainWnd::UpdateFoodImage()
 {
 {
 	//先判断并创建临时目录
 	//先判断并创建临时目录
-	std::string folderPath = CLewaimaiString::UnicodeToANSI(CSystem::GetProgramDir()) + "\\tmp\\image";
-	std::wstring ws_folderPath = CLewaimaiString::ANSIToUnicode(folderPath);
+	std::wstring ws_folderPath = CSystem::GetProgramDir() + L"\\tmp\\image";
 	if (!CSystem::IsDirExist(ws_folderPath))
 	if (!CSystem::IsDirExist(ws_folderPath))
 	{
 	{
-		LOG_INFO("folderPath:" << folderPath.c_str() << ",没有找到对应的目录,即将创建");
-		CSystem::CreateMultiLevel(folderPath);
+		LOG_INFO("folderPath:" << ws_folderPath.c_str() << ",没有找到对应的目录,即将创建");
+		CSystem::CreateMultiLevel(ws_folderPath);
 	}
 	}
 
 
 	CSqlite3 sqlite;
 	CSqlite3 sqlite;
@@ -1963,4 +1962,4 @@ void CMainWnd::UpdateRegisterHotKey()
 	UnregisterHotKey(m_hWnd, WM_MYHOTKEY_SHOUKUAN);
 	UnregisterHotKey(m_hWnd, WM_MYHOTKEY_SHOUKUAN);
 
 
 	RegisterHotKey(m_hWnd, WM_MYHOTKEY_SHOUKUAN, shoukuan_mod, shoukuan_vk);
 	RegisterHotKey(m_hWnd, WM_MYHOTKEY_SHOUKUAN, shoukuan_mod, shoukuan_vk);
-}
+}

+ 24 - 35
zhipuzi_pos_windows/wnd/CUpdateWnd.cpp

@@ -228,28 +228,6 @@ LRESULT CUpdateWnd::MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool
     return false;
     return false;
 }
 }
 
 
-std::string CUpdateWnd::GetFileNameFormUrl(std::string url)
-{
-	char fileName[512] = { 0 };
-
-	int urlLen = strlen(url.c_str());
-	char mUrl[512] = { 0 };
-	char fName[256] = { 0 };
-	strcpy_s(mUrl, url.c_str());
-	int cutIndex = 0;
-	int i = urlLen - 1, j = 0;
-	while (mUrl[--i] != '/');
-	i++;
-	while (mUrl[i] != '\0' && mUrl[i] != '?' &&mUrl[i] != '&')
-	{
-		fName[j++] = mUrl[i++];
-	}
-	fName[j] = '\0';
-	strcpy_s(fileName, fName);
-
-	return fileName;
-}
-
 double CUpdateWnd::getDownloadFileLength(std::string url)
 double CUpdateWnd::getDownloadFileLength(std::string url)
 {
 {
     CURL *easy_handle = NULL;
     CURL *easy_handle = NULL;
@@ -312,7 +290,7 @@ double CUpdateWnd::getDownloadFileLength(std::string url)
 
 
 void CUpdateWnd::Run()
 void CUpdateWnd::Run()
 {
 {
-	m_filepath = m_dir + GetFileNameFormUrl(m_url);
+	m_filepath = m_dir + CLewaimaiString::UTF8ToUnicode(CLewaimaiString::GetFilenameFromUrl(m_url));
 
 
     CURLcode res;
     CURLcode res;
 
 
@@ -330,26 +308,37 @@ void CUpdateWnd::Run()
             return;
             return;
         }
         }
 
 
-        fopen_s(&m_outfile, m_filepath.c_str(), "ab+");
+        errno_t fopenErr = _wfopen_s(&m_outfile, m_filepath.c_str(), L"ab+");
 
 
         curl_easy_setopt(m_curl, CURLOPT_URL, m_url.c_str());//在此要注意,此url必须是多字节
         curl_easy_setopt(m_curl, CURLOPT_URL, m_url.c_str());//在此要注意,此url必须是多字节
 
 
-		if (m_url.find("https://") == 0)
-		{
-			curl_easy_setopt(m_curl, CURLOPT_SSL_VERIFYPEER, false);
-			curl_easy_setopt(m_curl, CURLOPT_SSL_VERIFYHOST, false);
-		}
-		
+        if (m_url.find("https://") == 0)
+        {
+            curl_easy_setopt(m_curl, CURLOPT_SSL_VERIFYPEER, false);
+            curl_easy_setopt(m_curl, CURLOPT_SSL_VERIFYHOST, false);
+        }
+
         curl_easy_setopt(m_curl, CURLOPT_TIMEOUT, 0);
         curl_easy_setopt(m_curl, CURLOPT_TIMEOUT, 0);
-        curl_easy_setopt(m_curl, CURLOPT_WRITEDATA, m_outfile);
         curl_easy_setopt(m_curl, CURLOPT_WRITEFUNCTION, my_write_func);
         curl_easy_setopt(m_curl, CURLOPT_WRITEFUNCTION, my_write_func);
         curl_easy_setopt(m_curl, CURLOPT_NOPROGRESS, FALSE);
         curl_easy_setopt(m_curl, CURLOPT_NOPROGRESS, FALSE);
         curl_easy_setopt(m_curl, CURLOPT_PROGRESSFUNCTION, my_progress_func);
         curl_easy_setopt(m_curl, CURLOPT_PROGRESSFUNCTION, my_progress_func);
         curl_easy_setopt(m_curl, CURLOPT_PROGRESSDATA, NULL);//给下载进度回调函数传参数,在此是指针
         curl_easy_setopt(m_curl, CURLOPT_PROGRESSDATA, NULL);//给下载进度回调函数传参数,在此是指针
 
 
-        res = curl_easy_perform(m_curl);
+        if (fopenErr == 0 && m_outfile != nullptr)
+        {
+            curl_easy_setopt(m_curl, CURLOPT_WRITEDATA, m_outfile);
+            res = curl_easy_perform(m_curl);
 
 
-        fclose(m_outfile);
+            fclose(m_outfile);
+            m_outfile = nullptr;
+        }
+        else
+        {
+            // 无法打开文件时,清理 curl 并返回
+            curl_easy_cleanup(m_curl);
+            m_curl = nullptr;
+            return;
+        }
 
 
         curl_easy_cleanup(m_curl);
         curl_easy_cleanup(m_curl);
     }
     }
@@ -423,9 +412,9 @@ LRESULT CUpdateWnd::OnRefresh(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHa
 
 
 LRESULT CUpdateWnd::OnDownloadFinish(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
 LRESULT CUpdateWnd::OnDownloadFinish(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
 {
 {
-	HINSTANCE hNewExe = ShellExecuteA(NULL, "open", m_filepath.c_str(), NULL, NULL, SW_SHOW);
+	HINSTANCE hNewExe = ShellExecute(NULL, L"open", m_filepath.c_str(), NULL, NULL, SW_SHOW);
 
 
 	PostQuitMessage(0);
 	PostQuitMessage(0);
 
 
 	return 0;
 	return 0;
-}
+}

+ 3 - 5
zhipuzi_pos_windows/wnd/CUpdateWnd.h

@@ -24,7 +24,7 @@ public:
         delete this;
         delete this;
     };
     };
 
 
-	void InitData(std::string url, std::string dir)
+	void InitData(std::string url, std::wstring dir)
 	{
 	{
 		m_url = url;
 		m_url = url;
 		m_dir = dir;
 		m_dir = dir;
@@ -58,8 +58,6 @@ public:
 
 
 	LRESULT OnDownloadFinish(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
 	LRESULT OnDownloadFinish(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
 
 
-	std::string GetFileNameFormUrl(std::string url);
-
 	static size_t nousecb(char *buffer, size_t x, size_t y, void *userdata);
 	static size_t nousecb(char *buffer, size_t x, size_t y, void *userdata);
 
 
     double getDownloadFileLength(std::string url);
     double getDownloadFileLength(std::string url);
@@ -76,8 +74,8 @@ public:
 public:
 public:
     CPaintManagerUI m_pm;
     CPaintManagerUI m_pm;
 
 
-    std::string m_dir;//目录名
-	std::string m_filepath; //完成文件在本地的路径名
+    std::wstring m_dir;//目录名
+	std::wstring m_filepath; //完成文件在本地的路径名
 
 
 	CURL* m_curl;//libcurl句柄
 	CURL* m_curl;//libcurl句柄
 
 

+ 1 - 3
zhipuzi_pos_windows/worker/CDiandanAIShibieWorker.cpp

@@ -86,7 +86,7 @@ void CDiandanAIShibieWorker::DoAIShibie()
 			CSystem::CreateMultiLevel(CLewaimaiString::UnicodeToUTF8(save_path));
 			CSystem::CreateMultiLevel(CLewaimaiString::UnicodeToUTF8(save_path));
 		}
 		}
 
 
-		std::string filename = CLewaimaiString::generateRandomStr(32);
+		std::string filename = CLewaimaiString::GenerateRandomStr(32);
 		std::wstring file_save_path = save_path + L"\\" + CLewaimaiString::UTF8ToUnicode(filename) + L".jpg";
 		std::wstring file_save_path = save_path + L"\\" + CLewaimaiString::UTF8ToUnicode(filename) + L".jpg";
 
 
 		cv::imwrite(CLewaimaiString::UnicodeToUTF8(file_save_path), image);
 		cv::imwrite(CLewaimaiString::UnicodeToUTF8(file_save_path), image);
@@ -99,8 +99,6 @@ void CDiandanAIShibieWorker::DoAIShibie()
 			//识别成功
 			//识别成功
 			std::cout << "检测到类别: " << m_ai_shibie_foodname << std::endl;
 			std::cout << "检测到类别: " << m_ai_shibie_foodname << std::endl;
 
 
-			m_ai_shibie_foodname = CLewaimaiString::ANSIToUTF8(m_ai_shibie_foodname);
-
 			//主线程里面去处理界面刷新
 			//主线程里面去处理界面刷新
 			if (m_hwnd != NULL)
 			if (m_hwnd != NULL)
 			{
 			{

+ 2 - 2
zhipuzi_pos_windows/worker/CPosPrinterWorker.cpp

@@ -661,11 +661,11 @@ int CPosPrinterWorker::GetDevicePath(LPGUID lpGuid, std::vector<std::wstring>& u
 			//是否是要找的设备类型
 			//是否是要找的设备类型
 			if (ws_buf != strUSBPrint && ws_buf != strUSBPrint_EN)
 			if (ws_buf != strUSBPrint && ws_buf != strUSBPrint_EN)
 			{
 			{
-				LOG_INFO("not good usb, buf:" << CLewaimaiString::UnicodeToANSI(ws_buf).c_str());
+				LOG_INFO(L"not good usb, buf:" << ws_buf);
 				continue;
 				continue;
 			}
 			}
 
 
-			LOG_INFO("good usb, buf:" << CLewaimaiString::UnicodeToANSI(ws_buf).c_str());
+			LOG_INFO(L"good usb, buf:" << ws_buf);
 			ifData.cbSize = sizeof(ifData);
 			ifData.cbSize = sizeof(ifData);
 
 
 			// 枚舉符合該GUID的設備接口
 			// 枚舉符合該GUID的設備接口

+ 2 - 2
zhipuzi_pos_windows/zhipuzi/CFood.h

@@ -76,7 +76,7 @@ public:
 		}
 		}
 
 
 		//纯文件名
 		//纯文件名
-		std::string file_name = CLewaimaiString::GetPathOrURLShortName(goods_img);
+		std::string file_name = CLewaimaiString::GetFilenameFromUrl(goods_img);
 
 
 		//根据文件名,计算文件临时路径
 		//根据文件名,计算文件临时路径
 		std::wstring folderPath = CSystem::GetProgramDir() + L"\\tmp\\image\\";
 		std::wstring folderPath = CSystem::GetProgramDir() + L"\\tmp\\image\\";
@@ -84,4 +84,4 @@ public:
 
 
 		return imagePath;
 		return imagePath;
 	}
 	}
-};
+};

+ 2 - 2
zhipuzi_pos_windows/zhipuzi/CFoodpackage.h

@@ -58,7 +58,7 @@ public:
 		}
 		}
 
 
 		//纯文件名
 		//纯文件名
-		std::string file_name = CLewaimaiString::GetPathOrURLShortName(goods_img);
+		std::string file_name = CLewaimaiString::GetFilenameFromUrl(goods_img);
 
 
 		//根据文件名,计算文件临时路径
 		//根据文件名,计算文件临时路径
 		std::wstring folderPath = CSystem::GetProgramDir() + L"\\tmp\\image\\";
 		std::wstring folderPath = CSystem::GetProgramDir() + L"\\tmp\\image\\";
@@ -66,4 +66,4 @@ public:
 
 
 		return imagePath;
 		return imagePath;
 	}
 	}
-};
+};

+ 5 - 6
zhipuzi_pos_windows/zhipuzi/CShopinfo.cpp

@@ -81,16 +81,15 @@ void CShopinfo::InitShopinfoByLogin(rapidjson::Value& v_data)
 
 
 std::wstring CShopinfo::GetImageTmpPathFromUrl(std::string image_url)
 std::wstring CShopinfo::GetImageTmpPathFromUrl(std::string image_url)
 {
 {
-	std::string folderPath = CLewaimaiString::UnicodeToANSI(CSystem::GetProgramDir()) + "\\tmp\\image\\";
-	std::wstring ws_folderPath = CLewaimaiString::ANSIToUnicode(folderPath);
+	std::wstring ws_folderPath = CSystem::GetProgramDir() + L"\\tmp\\image\\";
 	if (!CSystem::IsDirExist(ws_folderPath))
 	if (!CSystem::IsDirExist(ws_folderPath))
 	{
 	{
-		LOG_INFO("folderPath:" << folderPath.c_str() << ",没有找到对应的目录,即将创建");
-		CSystem::CreateMultiLevel(folderPath);
+		LOG_INFO("folderPath:" << ws_folderPath.c_str() << ",没有找到对应的目录,即将创建");
+		CSystem::CreateMultiLevel(ws_folderPath);
 	}
 	}
 
 
 	//纯文件名
 	//纯文件名
-	std::string file_name = CLewaimaiString::GetPathOrURLShortName(image_url);
+	std::string file_name = CLewaimaiString::GetFilenameFromUrl(image_url);
 
 
 	//根据文件名,计算文件临时路径
 	//根据文件名,计算文件临时路径
 	std::wstring imagePath = ws_folderPath + CLewaimaiString::UTF8ToUnicode(file_name);
 	std::wstring imagePath = ws_folderPath + CLewaimaiString::UTF8ToUnicode(file_name);
@@ -471,4 +470,4 @@ bool CShopinfo::GetTabletypeInfo()
 	}
 	}
 
 
 	return true;
 	return true;
-}
+}

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません