| 1652 | // convert UTF-8 string to wstring |
| 1653 | #ifdef _MSC_VER |
| 1654 | static inline std::wstring utf8_decode(const std::string& s) { |
| 1655 | auto r = setlocale(LC_ALL, ""); |
| 1656 | std::string curLocale; |
| 1657 | if (r) |
| 1658 | curLocale = r; |
| 1659 | const char* _Source = s.c_str(); |
| 1660 | size_t _Dsize = std::strlen(_Source) + 1; |
| 1661 | wchar_t* _Dest = new wchar_t[_Dsize]; |
| 1662 | size_t _Osize; |
| 1663 | mbstowcs_s(&_Osize, _Dest, _Dsize, _Source, _Dsize); |
| 1664 | std::wstring result = _Dest; |
| 1665 | delete[] _Dest; |
| 1666 | setlocale(LC_ALL, curLocale.c_str()); |
| 1667 | return result; |
| 1668 | } |
| 1669 | #else |
| 1670 | static inline std::wstring utf8_decode(const std::string& s) { |
| 1671 | auto r = setlocale(LC_ALL, ""); |