Malformed UTF-8 sequences are no longer fatal
authorChristoph Sommer <mail@christoph-sommer.de>
Fri, 30 Jun 2006 15:31:02 +0000 (15:31 +0000)
committerChristoph Sommer <mail@christoph-sommer.de>
Fri, 30 Jun 2006 15:31:02 +0000 (15:31 +0000)
SVN-Revision: 3811

src/video/font.cpp

index 42aa455..2a41b2a 100644 (file)
@@ -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?