Re: WARNING **: Invalid UTF8 string passed to pango_layout_set_text()



On Wed, Nov 20, 2002 at 12:08:31AM +0100, Emmanuel Saracco wrote:
On Tue, 19 Nov 2002 22:15:09 +0100
Thijs Assies <thijs_a gmx net> wrote:

Hi,
When i run my program i get this error a few times: WARNING **:
Invalid UTF8 string passed to pango_layout_set_text()
and the text in the clist is f*cked up. How can i fix this??

does anyone knows?

try using g_utf8_normalize() to encode your strings.


g_utf8_normalize() is a relatively special-purpose thing, see
http://www.unicode.org/unicode/reports/tr15/ and the
g_utf8_normalize() docs.

The solution to "invalid utf-8" is simply to encode your text in
UTF-8.

If your text is currently latin-1, the conversion is something like:

    static char*
    utf8_from_latin1 (const char *latin1)
    {
      const char *p;
      GString *utf8;

      utf8 = g_string_new (NULL);
      p = latin1;
      while (*p)
        g_string_append_unichar (utf8, (gunichar) *p++);

      return g_string_free (utf8, FALSE);
    }

OK, written clearly instead of cutely ;-)
 
   for (p = latin1; *p != '\0'; p++)
     g_string_append_unichar (utf8, (gunichar) *p);

If your text is in locale encoding (encoding varies by LANG), use
g_locale_to_utf8().

Havoc





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]