From 629238ac36c248f43228d39801d3da7a471ebb55 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Mon, 11 Feb 2019 21:35:32 +0100 Subject: [PATCH] [util] Implement tows method to convert strings to wide strings --- src/util/util_string.cpp | 16 ++++++++++++++++ src/util/util_string.h | 3 +++ 2 files changed, 19 insertions(+) diff --git a/src/util/util_string.cpp b/src/util/util_string.cpp index 8e1eb0c71..c684ca0d7 100644 --- a/src/util/util_string.cpp +++ b/src/util/util_string.cpp @@ -22,4 +22,20 @@ namespace dxvk::str { &result.at(0), len, nullptr, nullptr); return result; } + + + std::vector tows(const std::string& str) { + int strLen = ::MultiByteToWideChar( + CP_ACP, 0, str.c_str(), str.length() + 1, + nullptr, 0); + + std::vector wideStr(strLen); + + ::MultiByteToWideChar( + CP_ACP, 0, str.c_str(), str.length() + 1, + wideStr.data(), strLen); + + return wideStr; + } + } diff --git a/src/util/util_string.h b/src/util/util_string.h index 3a176a35f..36807e12e 100644 --- a/src/util/util_string.h +++ b/src/util/util_string.h @@ -2,12 +2,15 @@ #include #include +#include #include "./com/com_include.h" namespace dxvk::str { std::string fromws(const WCHAR *ws); + + std::vector tows(const std::string& str); inline void format1(std::stringstream&) { }