From 224d9268ef10d481a81b6ba83993154d0e329f2c Mon Sep 17 00:00:00 2001 From: zeromus Date: Sun, 17 Aug 2008 19:27:58 +0000 Subject: [PATCH] handle a crash condition when I receive non-convertible utf-8 text --- src/utils/xstring.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils/xstring.cpp b/src/utils/xstring.cpp index c4e23643..04ee8e4f 100644 --- a/src/utils/xstring.cpp +++ b/src/utils/xstring.cpp @@ -679,7 +679,11 @@ namespace UtfConverter //convert a std::string to std::wstring std::wstring mbstowcs(std::string str) { - return UtfConverter::FromUtf8(str); + try { + return UtfConverter::FromUtf8(str); + } catch(std::exception) { + return L"(failed UTF-8 conversion)"; + } } std::string wcstombs(std::wstring str)