Re: glib/iconv : delayed dependency



Hans Breuer <hans breuer org> writes:

> At 10:47 14.05.01 +0300, Tor Lillqvist wrote:
> >Hans Breuer writes:
> > > fail because of a missing iconv.dll. (It is spitting a g_warning
> > > then.)
> >
> >Go ahead and commit, it's seems fine to me.
> >
> >I would replace the g_warning() calls if no iconv DLL can be found
> >with g_error(), though.
> >
> IMO a g_error would miss the point. Assuming that even g_convert with
> iconv may fail (i.e.: because of an unsupported converison) it should
> be in the responsibility of the app how to handle it. 
> This is what I'm doing in the Dia wmf plug-in (beware C++, W32 is
> the namespace wrapping the windows headers):
> 
> static void
> draw_string(MyRenderer *renderer,
> 	    const char *text,
> 	    Point *pos, Alignment alignment,
> 	    Color *colour)
> {
> // ...
>         char* scp; 
>         /* convert from utf8 to active codepage */
>         static char codepage[10];
>         sprintf (codepage, "CP%d", W32::GetACP ());
> 
>         scp = g_convert (text, strlen (text),
>                          codepage, "UTF-8",
>                          NULL, NULL, NULL);
>         if (scp)
>           {
>             W32::TextOut(renderer->hFileDC,
>                          SCX(pos->x), SCY(pos->y),
>                          scp, strlen(scp));
>             g_free (scp);
>           }
>         else
>           {
>             /* conversion failed, unconverted is better than nothing ? */
>             W32::TextOut(renderer->hFileDC,
>                          SCX(pos->x), SCY(pos->y),
p>                          text, strlen(text));
>           }

If I was maintaining an application, I'd reject code like this.
A conversion facility that "sometimes" works is useless.

I would expect g_get_charset() to return the character set for the
current codepage, and I'd expect g_iconv() to always handle that.

Regards,
                                        Owen




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