* 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.
static std::wstring_convert<std::codecvt_utf8_utf16<char16_t>,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);
}
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;