summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/util.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/shared/util.cpp b/src/shared/util.cpp
index 2ce88eca..75d80d83 100644
--- a/src/shared/util.cpp
+++ b/src/shared/util.cpp
@@ -22,6 +22,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include "error_report.h"
#include <sstream>
+#include <locale>
#include <algorithm>
#include <DbgHelp.h>
#include <set>
@@ -91,29 +92,38 @@ std::wstring ToWString(const std::string &source, bool utf8)
return result;
}
+static std::locale loc("");
+static auto locToLowerW = [] (wchar_t in) -> wchar_t {
+ return std::tolower(in, loc);
+};
+
+static auto locToLower = [] (char in) -> char {
+ return std::tolower(in, loc);
+};
+
std::string &ToLower(std::string &text)
{
- std::transform(text.begin(), text.end(), text.begin(), ::tolower);
+ std::transform(text.begin(), text.end(), text.begin(), locToLower);
return text;
}
std::string ToLower(const std::string &text)
{
std::string result = text;
- std::transform(result.begin(), result.end(), result.begin(), ::tolower);
+ std::transform(result.begin(), result.end(), result.begin(), locToLower);
return result;
}
std::wstring &ToLower(std::wstring &text)
{
- std::transform(text.begin(), text.end(), text.begin(), ::towlower);
+ std::transform(text.begin(), text.end(), text.begin(), locToLowerW);
return text;
}
std::wstring ToLower(const std::wstring &text)
{
std::wstring result = text;
- std::transform(result.begin(), result.end(), result.begin(), ::towlower);
+ std::transform(result.begin(), result.end(), result.begin(), locToLowerW);
return result;
}