From: Andrey Okoshkin Date: Wed, 7 Feb 2018 10:19:53 +0000 (+0300) Subject: Redesign of `to_utf8()` X-Git-Tag: submit/tizen/20180620.071641~20^2^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=03bea71019b354459cfd9ffac07e71bdcebf2c86;p=sdk%2Ftools%2Fnetcoredbg.git Redesign of `to_utf8()` * String length is not passed any more due to it's buggy implementation. * New overloaded version for a single wide-char is added. * `WCHAR` is not necessary to use in this header as `char16_t` has been already passed to the `std::codecvt_utf8_utf16` template. --- diff --git a/src/debug/netcoredbg/cputil.h b/src/debug/netcoredbg/cputil.h index b2563ef..c4b1e7f 100644 --- a/src/debug/netcoredbg/cputil.h +++ b/src/debug/netcoredbg/cputil.h @@ -8,11 +8,12 @@ static std::wstring_convert,char16_t> convert; -static inline std::string to_utf8(const WCHAR *wstr, int len = -1) +static inline std::string to_utf8(const char16_t *wstr) { - if (len == -1) - return convert.to_bytes(wstr); - if (len == 0) - return std::string(); - return convert.to_bytes(wstr, wstr + len); + return convert.to_bytes(wstr); +} + +static inline std::string to_utf8(char16_t wch) +{ + return convert.to_bytes(wch); } diff --git a/src/debug/netcoredbg/valueprint.cpp b/src/debug/netcoredbg/valueprint.cpp index 67b3494..46c378a 100644 --- a/src/debug/netcoredbg/valueprint.cpp +++ b/src/debug/netcoredbg/valueprint.cpp @@ -620,7 +620,7 @@ HRESULT PrintValue(ICorDebugValue *pInputValue, std::string &output, bool escape case ELEMENT_TYPE_CHAR: { WCHAR wc = * (WCHAR *) &(rgbValue[0]); - std::string printableVal = to_utf8(&wc, 1); + std::string printableVal = to_utf8(wc); if (!escape) { output = printableVal;