Re: gtk_init_with_args behavior



On Mon, 21 May 2018, tito-wolit wrote:

On 21/05/2018 01:27, Allin Cottrell wrote:

gtk_init_with_args is still useful in my case: it automatically screens out any command-line arguments that are just option flags or parameters, via the GOptionEntry mechanism, leaving only a filename argument to which my program has to respond (but which may be broken in plain argv). Fortunately, it works fine after conversion via g_utf16_to_utf8. So my workflow is:

GetCommandLineW
CommandLineToArgvW
convert array of UTF-16 strings to UTF-8
pass the converted array to gtk_init_with_args

Hi,
I use:

filename = g_locale_to_utf8((argv*), -1, NULL, NULL, NULL);
do something with filename
free(filename)

This works also on windows.

Ah, but it does NOT work in the case I'm talking about, where the filename in question is not representable in the current Windows Code Page, because it contains a mixture of character sets. Then the only way to get the real, non-mangled filename from Windows is in UTF-16 form via GetCommandLineW.

The problem arises only because Windows doesn't do UTF-8, and so cannot pass "exotic" filenames via C's argv.

Allin Cottrell




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