-inline std::wstring widen(const std::string& str, const std::locale& locale = std::locale())\r
-{\r
- std::wstringstream wsstr ;\r
- wsstr.imbue(locale);\r
- const std::ctype<wchar_t>& ctfacet = std::use_facet<std::ctype<wchar_t>>(wsstr.getloc()) ;\r
- for(size_t i = 0 ;i < str.size(); ++i)\r
- wsstr << ctfacet.widen(str[i]) ;\r
- return wsstr.str() ;\r
-}\r
-\r
-inline std::wstring widen(const std::wstring& str, const std::locale&)\r
-{\r
- return str;\r
-}\r
-\r
-#if defined(_MSC_VER)\r
-#pragma warning(push)\r
-#pragma warning(disable : 4244)\r
-#endif\r
- \r
-inline std::string narrow(const std::wstring& str, const std::locale& locale = std::locale())\r
-{\r
- std::stringstream sstr;\r
- sstr.imbue(locale);\r
- const std::ctype<char>& ctfacet = std::use_facet<std::ctype<char>>(sstr.getloc());\r
- for(size_t i = 0; i < str.size(); ++i)\r
- sstr << ctfacet.narrow(str[i], 0) ;\r
- return sstr.str() ;\r
-}\r
- \r
-inline std::string narrow(const std::string& str, const std::locale&)\r
-{\r
- return str ;\r
-}\r
-\r
-#if defined(_MSC_VER)\r
-#pragma warning(pop)\r
-#endif\r
-//\r
-//inline std::string narrow_to_latin1(const std::wstring& wideString)\r
-//{\r
-// std::string destBuffer;\r
-// //28591 = ISO 8859-1 Latin I\r
-// int bytesWritten = 0;\r
-// int multibyteBufferCapacity = WideCharToMultiByte(28591, 0, wideString.c_str(), -1, 0, 0, \r
-// nullptr, nullptr);\r
-// if(multibyteBufferCapacity > 0) \r
-// {\r
-// destBuffer.resize(multibyteBufferCapacity);\r
-// bytesWritten = WideCharToMultiByte(28591, 0, wideString.c_str(), -1, &destBuffer[0], \r
-// destBuffer.size(), nullptr, nullptr);\r
-// }\r
-// destBuffer.resize(bytesWritten);\r
-// return destBuffer;\r
-//}\r