Workaround a SDL_TTF bug that makes it crash...

...when presented an invalid UTF-8 string.
This commit is contained in:
Philippe Plantier 2004-08-05 20:42:11 +00:00
parent 07e5ee173d
commit 4d8664be25

View file

@ -208,7 +208,11 @@ surface render_text_internal(TTF_Font* font,const std::string& str,
if(r.w > max_text_line_width)
return NULL;
return TTF_RenderUTF8_Blended(font,str.c_str(),colour);
// Validate the UTF-8 string: workaround a SDL_TTF bug that makes it
// crash when used with an invalid UTF-8 string
std::string fixed_str = wstring_to_string(string_to_wstring(str));
return TTF_RenderUTF8_Blended(font,fixed_str.c_str(),colour);
}