mirror of
https://github.com/minetest/minetest.git
synced 2024-08-19 04:54:18 +02:00
Use MT's string conversion inside Irrlicht
This commit is contained in:
parent
b9adf244e5
commit
30e280b694
@ -6,13 +6,18 @@
|
|||||||
|
|
||||||
#include "irrTypes.h"
|
#include "irrTypes.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <string_view>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cwchar>
|
#include <cwchar>
|
||||||
#include <codecvt>
|
|
||||||
#include <locale>
|
#include <locale>
|
||||||
|
|
||||||
|
/* HACK: import these string methods from MT's util/string.h */
|
||||||
|
extern std::wstring utf8_to_wide(std::string_view input);
|
||||||
|
extern std::string wide_to_utf8(std::wstring_view input);
|
||||||
|
/* */
|
||||||
|
|
||||||
namespace irr
|
namespace irr
|
||||||
{
|
{
|
||||||
namespace core
|
namespace core
|
||||||
@ -905,8 +910,7 @@ inline size_t multibyteToWString(stringw &destination, const core::stringc &sour
|
|||||||
|
|
||||||
inline size_t utf8ToWString(stringw &destination, const char *source)
|
inline size_t utf8ToWString(stringw &destination, const char *source)
|
||||||
{
|
{
|
||||||
std::wstring_convert<std::codecvt_utf8<wchar_t>> conv;
|
destination = utf8_to_wide(source);
|
||||||
destination = conv.from_bytes(source);
|
|
||||||
return destination.size();
|
return destination.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -917,8 +921,7 @@ inline size_t utf8ToWString(stringw &destination, const stringc &source)
|
|||||||
|
|
||||||
inline size_t wStringToUTF8(stringc &destination, const wchar_t *source)
|
inline size_t wStringToUTF8(stringc &destination, const wchar_t *source)
|
||||||
{
|
{
|
||||||
std::wstring_convert<std::codecvt_utf8<wchar_t>> conv;
|
destination = wide_to_utf8(source);
|
||||||
destination = conv.to_bytes(source);
|
|
||||||
return destination.size();
|
return destination.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,8 +38,6 @@ elseif(MSVC)
|
|||||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||||
add_compile_options(/arch:SSE)
|
add_compile_options(/arch:SSE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_compile_options(/D_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Platform-independent configuration (hard-coded currently)
|
# Platform-independent configuration (hard-coded currently)
|
||||||
|
Loading…
Reference in New Issue
Block a user