From dd14396b0af0193dcc6f5ebde61b5d6e9533643d Mon Sep 17 00:00:00 2001 From: lifegpc Date: Wed, 7 May 2025 15:20:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=200=20=E9=95=BF=E5=BA=A6?= =?UTF-8?q?=E7=9A=84=E5=AD=97=E7=AC=A6=E8=BD=AC=E6=8D=A2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wchar_util.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/wchar_util.cpp b/wchar_util.cpp index 448057a..35ee8c7 100644 --- a/wchar_util.cpp +++ b/wchar_util.cpp @@ -69,6 +69,10 @@ unsigned long wchar_util::getWideCharToMultiByteOptions(const unsigned long ori_ } bool wchar_util::str_to_wstr(std::wstring& out, std::string inp, unsigned int cp, unsigned long options) { + if (inp.empty()) { + out = std::wstring(); + return true; + } DWORD opt = getMultiByteToWideCharOptions(options, cp); int wlen = MultiByteToWideChar(cp, opt, inp.c_str(), inp.length(), nullptr, 0); if (!wlen) { @@ -88,6 +92,10 @@ bool wchar_util::str_to_wstr(std::wstring& out, std::string inp, unsigned int cp } bool wchar_util::wstr_to_str(std::string& out, std::wstring inp, unsigned int cp, unsigned long options) { + if (inp.empty()) { + out = std::string(); + return true; + } DWORD opt = getWideCharToMultiByteOptions(options, cp); int len = WideCharToMultiByte(cp, opt, inp.c_str(), inp.length(), nullptr, 0, nullptr, nullptr); if (!len) {