Re: glib/iconv : delayed dependency



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),
                         text, strlen(text));
          }

Regards,
	Hans
-------- Hans "at" Breuer "dot" Org -----------
Tell me what you need, and I'll tell you how to 
get along without it.                -- Dilbert




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