Implement UTF-8 conversion using codecvt
This commit is contained in:
parent
7f8455f731
commit
60a9e8fb7e
@ -26,6 +26,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <string.h> // strerror_r() and strerror_s()
|
#include <string.h> // strerror_r() and strerror_s()
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <codecvt> // new in C++11
|
||||||
|
|
||||||
#include "strutils.hxx"
|
#include "strutils.hxx"
|
||||||
|
|
||||||
@ -401,6 +402,8 @@ std::wstring convertUtf8ToWString(const std::string& a)
|
|||||||
#ifdef SG_WINDOWS
|
#ifdef SG_WINDOWS
|
||||||
return convertMultiByteToWString(CP_UTF8, a);
|
return convertMultiByteToWString(CP_UTF8, a);
|
||||||
#else
|
#else
|
||||||
|
std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> ucs2conv;
|
||||||
|
return ucs2conv.from_bytes(a);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -409,7 +412,8 @@ std::string convertWStringToUtf8(const std::wstring& w)
|
|||||||
#ifdef SG_WINDOWS
|
#ifdef SG_WINDOWS
|
||||||
return convertWStringToMultiByte(CP_UTF8, w);
|
return convertWStringToMultiByte(CP_UTF8, w);
|
||||||
#else
|
#else
|
||||||
|
std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> ucs2conv;
|
||||||
|
return ucs2conv.to_bytes(w);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user