We require C++11 now, simplify this code.

This ensures wstring to std::string conversion is always available,
needed for some HID work I’m doing on a branch,.
This commit is contained in:
James Turner 2017-10-29 13:20:39 +00:00
parent 2a60e5e338
commit 2642299d77

View File

@ -29,10 +29,7 @@
#include <cstring> // strerror_r() and strerror_s()
#include <cctype>
#include <cerrno>
#if defined(HAVE_CPP11_CODECVT)
#include <codecvt> // new in C++11
#endif
#include <codecvt>
#include "strutils.hxx"
@ -656,26 +653,14 @@ static std::string convertWStringToMultiByte(DWORD encoding, const std::wstring&
std::wstring convertUtf8ToWString(const std::string& a)
{
#ifdef SG_WINDOWS
return convertMultiByteToWString(CP_UTF8, a);
#elif defined(HAVE_CPP11_CODECVT)
std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> ucs2conv;
return ucs2conv.from_bytes(a);
#else
return std::wstring();
#endif
}
std::string convertWStringToUtf8(const std::wstring& w)
{
#ifdef SG_WINDOWS
return convertWStringToMultiByte(CP_UTF8, w);
#elif defined(HAVE_CPP11_CODECVT)
std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> ucs2conv;
return ucs2conv.to_bytes(w);
#else
return std::string();
#endif
}
std::string convertWindowsLocal8BitToUtf8(const std::string& a)