MCPcopy Create free account
hub / github.com/KTH-RPL/dufomap / utf8_decode

Function utf8_decode

src/indicators.hpp:1654–1668  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1652// convert UTF-8 string to wstring
1653#ifdef _MSC_VER
1654static 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
1670static inline std::wstring utf8_decode(const std::string& s) {
1671 auto r = setlocale(LC_ALL, "");

Callers 1

display_widthFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected