Skip to content

Commit

Permalink
Use MT's string conversion inside Irrlicht
Browse files Browse the repository at this point in the history
  • Loading branch information
sfan5 committed Apr 6, 2024
1 parent f02dc12 commit c3529cb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 8 additions & 5 deletions irr/include/irrString.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@

#include "irrTypes.h"
#include <string>
#include <string_view>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cwchar>
#include <codecvt>
#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 core
Expand Down Expand Up @@ -905,8 +910,7 @@ inline size_t multibyteToWString(stringw &destination, const core::stringc &sour

inline size_t utf8ToWString(stringw &destination, const char *source)
{
std::wstring_convert<std::codecvt_utf8<wchar_t>> conv;
destination = conv.from_bytes(source);
destination = utf8_to_wide(source);
return destination.size();
}

Expand All @@ -917,8 +921,7 @@ inline size_t utf8ToWString(stringw &destination, const stringc &source)

inline size_t wStringToUTF8(stringc &destination, const wchar_t *source)
{
std::wstring_convert<std::codecvt_utf8<wchar_t>> conv;
destination = conv.to_bytes(source);
destination = wide_to_utf8(source);
return destination.size();
}

Expand Down
2 changes: 0 additions & 2 deletions irr/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ elseif(MSVC)
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
add_compile_options(/arch:SSE)
endif()

add_compile_options(/D_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING)
endif()

# Platform-independent configuration (hard-coded currently)
Expand Down

0 comments on commit c3529cb

Please sign in to comment.