From: Christoph Sommer Date: Fri, 30 Jun 2006 15:31:02 +0000 (+0000) Subject: Malformed UTF-8 sequences are no longer fatal X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=77bca8f2bcab6006e3d31abb758da877ca2e0f4a;p=supertux.git Malformed UTF-8 sequences are no longer fatal SVN-Revision: 3811 --- diff --git a/src/video/font.cpp b/src/video/font.cpp index 42aa45583..2a41b2a13 100644 --- a/src/video/font.cpp +++ b/src/video/font.cpp @@ -223,7 +223,15 @@ Font::draw_chars(Surface* pchars, const std::string& text, const Vector& pos, Vector p = pos; size_t i = 0; while(i < text.size()) { - uint32_t c = decode_utf8(text, i); + uint32_t c; + try { + c = decode_utf8(text, i); + } + catch (std::runtime_error) { + log_debug << "Malformed utf-8 sequence beginning with " << *((uint32_t*)(text.c_str() + i)) << " found " << std::endl; + c = 0; + i++; + } ssize_t font_index; // a non-printable character?