diff --git a/examples/AutomatedTest/main.cpp b/examples/AutomatedTest/main.cpp index 888dae7ca..99fa5a96a 100644 --- a/examples/AutomatedTest/main.cpp +++ b/examples/AutomatedTest/main.cpp @@ -1,21 +1,7 @@ -#include #include -#include #include #include "exampleHelper.h" -// usually provided by Minetest -std::wstring utf8_to_wide(const std::string &input) { - assert(false); - return L"false"; -} - -// usually provided by Minetest -std::string wide_to_utf8(const std::wstring &input) { - assert(false); - return "false"; -} - using namespace irr; static IrrlichtDevice *device = nullptr; diff --git a/include/irrString.h b/include/irrString.h index 576ea2559..9164697c1 100644 --- a/include/irrString.h +++ b/include/irrString.h @@ -11,9 +11,8 @@ #include #include #include - -extern std::wstring utf8_to_wide(const std::string &input); -extern std::string wide_to_utf8(const std::wstring &input); +#include +#include namespace irr { @@ -866,10 +865,10 @@ class string return ret.size()-oldSize; } - friend size_t multibyteToWString(irr::core::stringw &destination, const irr::core::stringc &source); - friend size_t multibyteToWString(irr::core::stringw &destination, const char *source); - friend size_t wStringToMultibyte(irr::core::stringc &destination, const irr::core::stringw &source); - friend size_t wStringToMultibyte(irr::core::stringc &destination, const wchar_t *source); + friend size_t multibyteToWString(stringw &destination, const stringc &source); + friend size_t multibyteToWString(stringw &destination, const char *source); + friend size_t wStringToMultibyte(stringc &destination, const stringw &source); + friend size_t wStringToMultibyte(stringc &destination, const wchar_t *source); private: @@ -922,27 +921,31 @@ class string }; -inline size_t multibyteToWString(irr::core::stringw &destination, const irr::core::stringc &source) +inline size_t multibyteToWString(stringw &destination, const stringc &source) { - destination = utf8_to_wide(source.str); + std::wstring_convert> conv; + destination = conv.from_bytes(source.str); return destination.size(); } -inline size_t multibyteToWString(irr::core::stringw &destination, const char *source) +inline size_t multibyteToWString(stringw &destination, const char *source) { - destination = utf8_to_wide(source); + std::wstring_convert> conv; + destination = conv.from_bytes(source); return destination.size(); } -inline size_t wStringToMultibyte(irr::core::stringc &destination, const irr::core::stringw &source) +inline size_t wStringToMultibyte(stringc &destination, const stringw &source) { - destination = wide_to_utf8(source.str); + std::wstring_convert> conv; + destination = conv.to_bytes(source.str); return destination.size(); } -inline size_t wStringToMultibyte(irr::core::stringc &destination, const wchar_t *source) +inline size_t wStringToMultibyte(stringc &destination, const wchar_t *source) { - destination = wide_to_utf8(source); + std::wstring_convert> conv; + destination = conv.to_bytes(source); return destination.size(); }