jeroen clarysse
2016-11-07 11:34:07 UTC
given a std::wstring variable named m_text, I do the following :
size_t s = 2 * sizeof(wchar_t)*(m_text.size() + 1);
char * convertedChar = (char*) malloc(s);
size_t res=0;
ppw_wcstombs(&res, convertedChar, s, m_text.c_str(), m_text.size());
convertedChar[m_text.size()] = 0;
SDL_Surface *msg1Sur = TTF_RenderUTF8_Blended_Wrapped(m_font->get_ttf_font(), convertedChar, m_fontcolor, (Uint32)m_force_width);
this works nicely as long as the input string doesn’t contain unicode characters. As soon as I use something like a curly quote (“) the drawing stops right before that character
can anyone point me what I’m doing wrong ?
size_t s = 2 * sizeof(wchar_t)*(m_text.size() + 1);
char * convertedChar = (char*) malloc(s);
size_t res=0;
ppw_wcstombs(&res, convertedChar, s, m_text.c_str(), m_text.size());
convertedChar[m_text.size()] = 0;
SDL_Surface *msg1Sur = TTF_RenderUTF8_Blended_Wrapped(m_font->get_ttf_font(), convertedChar, m_fontcolor, (Uint32)m_force_width);
this works nicely as long as the input string doesn’t contain unicode characters. As soon as I use something like a curly quote (“) the drawing stops right before that character
can anyone point me what I’m doing wrong ?