From 7fd918f32d9125c8e1a9b6025236098b242049ea Mon Sep 17 00:00:00 2001 From: LAGonauta Date: Tue, 23 Feb 2021 07:04:43 -0300 Subject: [PATCH] Fix string conversion --- plugins/windows-notification/api/src/converter.cpp | 12 ------------ plugins/windows-notification/api/src/win32.cpp | 2 ++ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/plugins/windows-notification/api/src/converter.cpp b/plugins/windows-notification/api/src/converter.cpp index f97cd4f3..b6ab3c7b 100644 --- a/plugins/windows-notification/api/src/converter.cpp +++ b/plugins/windows-notification/api/src/converter.cpp @@ -3,18 +3,6 @@ #include "converter.hpp" // Convert a wide Unicode string to an UTF8 string -std::string wstr_to_str(const std::wstring_view wstr) -{ - if(wstr.empty()) - { - return std::string(); - } - int final_size = WideCharToMultiByte(CP_UTF8, 0, wstr.data(), (int)wstr.size(), nullptr, 0, nullptr, nullptr); - std::string strTo(final_size, 0); - WideCharToMultiByte(CP_UTF8, 0, wstr.data(), (int)wstr.size(), strTo.data(), final_size, nullptr, nullptr); - return strTo; -} - char* wsview_to_char(const std::wstring_view wstr) { if(wstr.empty()) diff --git a/plugins/windows-notification/api/src/win32.cpp b/plugins/windows-notification/api/src/win32.cpp index 15612581..711ba385 100644 --- a/plugins/windows-notification/api/src/win32.cpp +++ b/plugins/windows-notification/api/src/win32.cpp @@ -10,6 +10,7 @@ std::optional GetCurrentModulePath() auto charWritten = GetModuleFileName(nullptr, exePath.data(), exePath.size()); if (charWritten > 0) { + exePath.resize(charWritten); return exePath; } return std::nullopt; @@ -21,6 +22,7 @@ std::optional GetShortcutPath() auto charWritten = GetEnvironmentVariable(L"APPDATA", shortcutPath.data(), shortcutPath.size()); if (charWritten > 0) { + shortcutPath.resize(charWritten); return shortcutPath; } return std::nullopt;