From: Igor Kulaychuk Date: Wed, 22 Aug 2018 16:58:27 +0000 (+0300) Subject: Fix unicode string convertion on Windows X-Git-Tag: accepted/tizen/unified/20180921.143126~2^2~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=69f781f2d8eed870605b7e8c771e3723b51fab9e;p=sdk%2Ftools%2Fnetcoredbg.git Fix unicode string convertion on Windows --- diff --git a/src/debug/netcoredbg/CMakeLists.txt b/src/debug/netcoredbg/CMakeLists.txt index dd156ee..5eb428a 100644 --- a/src/debug/netcoredbg/CMakeLists.txt +++ b/src/debug/netcoredbg/CMakeLists.txt @@ -39,6 +39,7 @@ set(netcoredbg_SRC vscodeprotocol.cpp frames.cpp jmc.cpp + cputil.cpp expr.cpp) set(CMAKE_INCLUDE_CURRENT_DIR ON) diff --git a/src/debug/netcoredbg/cputil.cpp b/src/debug/netcoredbg/cputil.cpp new file mode 100644 index 0000000..676506d --- /dev/null +++ b/src/debug/netcoredbg/cputil.cpp @@ -0,0 +1,39 @@ +#include "cputil.h" + +#include +#include + +#ifdef _MSC_VER + +static std::wstring_convert,wchar_t> convert; + +std::string to_utf8(const wchar_t *wstr) +{ + return convert.to_bytes(wstr); +} + +#else + +static std::wstring_convert,char16_t> convert; + +std::string to_utf8(const char16_t *wstr) +{ + return convert.to_bytes(wstr); +} + +#endif + +std::string to_utf8(char16_t wch) +{ + return convert.to_bytes(wch); +} + +#ifdef _MSC_VER +std::wstring +#else +std::u16string +#endif +to_utf16(const std::string &utf8) +{ + return convert.from_bytes(utf8); +} diff --git a/src/debug/netcoredbg/cputil.h b/src/debug/netcoredbg/cputil.h index 2c6b672..8e6c3f5 100644 --- a/src/debug/netcoredbg/cputil.h +++ b/src/debug/netcoredbg/cputil.h @@ -4,22 +4,13 @@ #pragma once #include -#include -#include -static std::wstring_convert,char16_t> convert; +#ifdef _MSC_VER +std::string to_utf8(const wchar_t *wstr); +std::wstring to_utf16(const std::string &utf8); +#else +std::string to_utf8(const char16_t *wstr); +std::u16string to_utf16(const std::string &utf8); +#endif -static inline std::string to_utf8(const char16_t *wstr) -{ - return convert.to_bytes(wstr); -} - -static inline std::string to_utf8(char16_t wch) -{ - return convert.to_bytes(wch); -} - -static inline std::u16string to_utf16(const std::string &utf8) -{ - return convert.from_bytes(utf8); -} +std::string to_utf8(char16_t wch);