Re: Main Loop, IO Channels and my CLI



Øystein Johansen writes:
 > (I'm using win32 command prompt window)

And GIOChannel watches work? Wow, I'm amazed. Or actually, in the case
of watches for GIOChannels associated with C file descriptors on
Win32, GLib uses a separate thread that sits most of the time blocked
waiting to read() from the file descriptor, so I guess indeed there is
no reason why it wouldn't work for terminal input.

 > Invalid byte sequence in conversion input

 > Can this be a bug? It work fine unless I use a special scandinavian
 > letter in my commands. Do I have to convert my string at any time?
 > How?

I think the input you get from a console window is typically in the
so-called OEM code page of your Windows installation. You need to call
the GetConsoleCP() function to find out the codepage of the console,
and then form the encoding name as a string like "CP437", and tell the
GIOChannel to use that encoding. Something like:

char codepage[10];
...
sprintf (codepage, "CP%d", GetConsoleCP ());
...
g_io_channel_set_encoding (channel, codepage, &error);

(Totally untested, tell us if it works ;)

Otherwise GLib assumes the data is in UTF-8, and reading *lines* from
a GIOChannel indeed requires it to know the actual encoding of the
data, so it will complain when the data isn't proper UTF-8.

--tml




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