From 199b8e7c321032d63434f9aecd718abfbb4c7970 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Mon, 24 Aug 2015 21:02:10 -1000 Subject: [PATCH] Removed codecvt --- hecl/extern/Athena | 2 +- hecl/extern/LogVisor | 2 +- hecl/lib/WideStringConvert.cpp | 25 +++++++++++++++++++------ 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/hecl/extern/Athena b/hecl/extern/Athena index 92898661c..66cb6c982 160000 --- a/hecl/extern/Athena +++ b/hecl/extern/Athena @@ -1 +1 @@ -Subproject commit 92898661cc318e2de2934e58607e8349a0d10d13 +Subproject commit 66cb6c982e8824fa887807bf8ba42376b301478b diff --git a/hecl/extern/LogVisor b/hecl/extern/LogVisor index 34f2f028a..154b84413 160000 --- a/hecl/extern/LogVisor +++ b/hecl/extern/LogVisor @@ -1 +1 @@ -Subproject commit 34f2f028a9e0c12b6827e93f7043339fecd84b75 +Subproject commit 154b84413050cdb03f281c42861b9af6eaef7d14 diff --git a/hecl/lib/WideStringConvert.cpp b/hecl/lib/WideStringConvert.cpp index 531ab0e9e..e674832fe 100644 --- a/hecl/lib/WideStringConvert.cpp +++ b/hecl/lib/WideStringConvert.cpp @@ -1,20 +1,33 @@ #include "HECL/HECL.hpp" -#include -#include namespace HECL { std::string WideToUTF8(const std::wstring& src) { - std::wstring_convert> conv; - return conv.to_bytes(src); + std::string retval; + retval.reserve(src.length()); + for (wchar_t ch : src) + { + char mb[4]; + int c = std::wctomb(mb, ch); + retval.append(mb, c); + } + return retval; } std::wstring UTF8ToWide(const std::string& src) { - std::wstring_convert> conv; - return conv.from_bytes(src); + std::wstring retval; + retval.reserve(src.length()); + const char* buf = src.c_str(); + while (*buf) + { + wchar_t wc; + buf += std::mbtowc(&wc, buf, MB_CUR_MAX); + retval += wc; + } + return retval; } }