[rrd-developers] UTF-8 and pango ... again

Tobias Oetiker tobi at oetiker.ch
Sat Aug 8 11:33:56 CEST 2009


Hi Sebastian,

Jul 21 Sebastian Harl wrote:

> Hi,
>
> The following problem has been reported to me:
>
> When creating graphs covering one year and using something like
> LANG=en_US.UTF-8 and LC_TIME="de_DE" in the environment, pango reports
> the following warning:
>
> Pango-WARNING **: Invalid UTF-8 string passed to pango_layout_set_text()

what happens when you set

LC_TIME=de_DE.UTF-8

cheers
tobi



> The graph uses the months as x-axis labels, which includes the string
> "MÀrz" ("March" in German). The umlaut ('À') ends up being messed up in
> the generated graph.
>
> I suppose that the problem is the following:
>
> rrd_graph.c uses strftime() to format the time which uses LC_TIME to
> determine the locale settings. Thus, in this case, the formatted date
> probably ends up not being encoded in UTF-8.
>
> The string is then passed to gfx_prep_text() (via gfx_text()) which uses
> g_locale_to_utf8() to convert the string from the local encoding to
> UTF-8 (which is required by pango). Now, g_locale_to_utf8() probably
> determines the locale settings from LANG and thus decides, in this case,
> that nothing needs to be done.
>
> I currently don't have any ideas how to properly solve that. One could
> argue that the locale settings are messed up and that it's the users own
> damn fault. However, I've never seen similar problems in other pieces of
> software, so there ought to be some way to solve that.
>
> Well, RRDtool could parse all relevant LC_* environment variables and
> then handle the situation appropriately. That'd probably be a whole lot
> of ugly work though, so it would be nice if somebody could think of a
> better solution. Changing the locale setting inside RRDtool does not
> sound like a valid solution either, since, then, strings passed on the
> command line would no longer be handled appropriately.
>
> Any ideas?
>
> Cheers,
> Sebastian
>
>

-- 
Tobi Oetiker, OETIKER+PARTNER AG, Aarweg 15 CH-4600 Olten, Switzerland
http://it.oetiker.ch tobi at oetiker.ch ++41 62 775 9902 / sb: -9900


More information about the rrd-developers mailing list