From 31459a624335a1d94b8c8bb5a6a6bce0cfa6c64a Mon Sep 17 00:00:00 2001 From: Charles A Edwards Date: Mon, 25 Jul 2016 11:32:30 +0100 Subject: [PATCH] Missing function added back (#62) Utf8ToUpperOnlyLatin was missing from Util.h and Util.cpp. This function is only executed for the CATA core. This was resulting in build errors under Windows and Visual Studio. Code taken from Trinitycore, as that was the only version I could find. Thank you, Trinitycore :-) --- src/modules/Eluna/GlobalMethods.h | 1 + src/shared/Utilities/Util.cpp | 11 +++++++++++ src/shared/Utilities/Util.h | 8 ++++++++ 3 files changed, 20 insertions(+) diff --git a/src/modules/Eluna/GlobalMethods.h b/src/modules/Eluna/GlobalMethods.h index c487576fe..36094c576 100644 --- a/src/modules/Eluna/GlobalMethods.h +++ b/src/modules/Eluna/GlobalMethods.h @@ -8,6 +8,7 @@ #define GLOBALMETHODS_H #include "ElunaBinding.h" +#include "Util.h" /*** * These functions can be used anywhere at any time, including at start-up. diff --git a/src/shared/Utilities/Util.cpp b/src/shared/Utilities/Util.cpp index b28460e16..91b0ac584 100644 --- a/src/shared/Utilities/Util.cpp +++ b/src/shared/Utilities/Util.cpp @@ -375,6 +375,17 @@ void utf8truncate(std::string& utf8str, size_t len) } } +bool Utf8ToUpperOnlyLatin(std::string& utf8String) +{ + std::wstring wstr; + if (!Utf8toWStr(utf8String, wstr)) + return false; + + std::transform(wstr.begin(), wstr.end(), wstr.begin(), wcharToUpperOnlyLatin); + + return WStrToUtf8(wstr, utf8String); +} + bool Utf8toWStr(char const* utf8str, size_t csize, wchar_t* wstr, size_t& wsize) { try diff --git a/src/shared/Utilities/Util.h b/src/shared/Utilities/Util.h index 6891c9efd..5ff3c1f86 100644 --- a/src/shared/Utilities/Util.h +++ b/src/shared/Utilities/Util.h @@ -252,6 +252,14 @@ inline void ApplyPercentModFloatVar(float& var, float val, bool apply) var *= (apply ? (100.0f + val) / 100.0f : 100.0f / (100.0f + val)); } +/** + * @brief + * + * @param utf8String + * @return bool + */ +bool Utf8ToUpperOnlyLatin(std::string& utf8String); + /** * @brief *