Re: [win32] Glib::IOChannel error?
- From: Köntös Eszter <eszter kontos gmail com>
- To: Armin Burgmeier <armin arbur net>
- Cc: gtkmm-list gnome org
- Subject: Re: [win32] Glib::IOChannel error?
- Date: Sat, 15 Nov 2008 18:17:41 +0100
Thank you very much, it works fine now:
#ifdef WIN32
ioch_in_=Glib::IOChannel::create_from_win32_fd(stdin_);
ioch_out_=Glib::IOChannel::create_from_win32_fd(stdout_);
ioch_err_=Glib::IOChannel::create_from_win32_fd(stderr_);
std::string locale;
Glib::get_charset(locale);
if (locale.length()>0) {
ioch_in_->set_encoding(locale);
ioch_out_->set_encoding(locale);
ioch_err_->set_encoding(locale);
std::cout << "Local set: " << locale << std::endl;
} else {
ioch_in_->set_encoding("");
ioch_out_->set_encoding("");
ioch_err_->set_encoding("");
std::cout << "Local set: <binary>" << std::endl;
}
#else
ioch_in_=Glib::IOChannel::create_from_fd(stdin_);
ioch_out_=Glib::IOChannel::create_from_fd(stdout_);
ioch_err_=Glib::IOChannel::create_from_fd(stderr_);
#endif
Armin Burgmeier wrote:
> On Fri, 2008-11-14 at 18:11 +0100, Köntös Eszter wrote:
>
>> Hi all,
>>
>> I'm writing a crossplatform program that executes another application
>> and reads from it's output. I'm using Glib::spawn_async_with_pipes to
>> solve the process handling and i handle the pipes with Glib::IOChannel.
>> The problem is that, if the application writes a string to it's output
>> that contains central-european characters (like: á, é, ü, ő, etc.) than
>> Glib::IOChannel::read_line throws the following exception:
>>
>
> Glib::IOChannel does implicit charset conversion, though I'm not exactly
> sure from what to what. But if you know the program you are spawning
> uses some specific character set (such as ISO-8859-2 (Central European))
> for output, and expect to receive it as such in your application, then
> you can try to disable that automatic charset conversion via
> some_io_channel->set_encoding("");
>
>
>> glibmm-CRITICAL ** :
>> unhandled exception (type: Glib::Error) in signal handler:
>> domain: g_convert_error
>> code: 1
>> what: invalid byte sequence in conversion input /the message is
>> localized so i tried to translate it to english, hope it's fits to the
>> original message/
>>
>> I have to use central-european charset, but i don't have any idea, how
>> to solve this problem. Furthermore i can't catch any exceptions
>> /Glib::IOChannelError or Glib::ConvertError, nor Glib::Error/, except (...).
>>
>
> If you are using the official gtkmm installer, then this might be
> because of ABI incomptabilities between your Compiler (gcc 4.2.1) and
> the one the official binaries were built with (gcc 3.4.5). You'll also
> have trouble catching other exceptions thrown by glibmm or gtkmm then.
>
>
>> This exception thrown only on windows; on linux everything works
>> perfectly. I'm using MinGW compiler (gcc-4.2.1-sjlj-2,
>> mingw32-make-3.81, mingwrt-3.15, w32api-3.12, binutils-2.18.50),
>> gtk-2.14.4-1, gtkmm-2.14.1-3 and windows-1250 charset.
>>
>> The code:
>> void ProcessHandler::spawn(const Glib::ArrayHandle<std::string>& argv)
>> {
>> try {
>> Glib::spawn_async_with_pipes(Glib::get_current_dir(),
>> argv,
>> Glib::SpawnFlags(0)|Glib::SPAWN_SEARCH_PATH,
>> sigc::slot<void>(),
>> &child_,&stdin_,&stdout_,&stderr_);
>> } catch (Glib::SpawnError& ex) {...}
>> } catch (Glib::Error& ex) {...}
>> ...
>> #ifdef WIN32
>> ioch_in_=Glib::IOChannel::create_from_win32_fd(stdin_);
>> ioch_out_=Glib::IOChannel::create_from_win32_fd(stdout_);
>> ioch_err_=Glib::IOChannel::create_from_win32_fd(stderr_);
>> #else
>> ioch_in_=Glib::IOChannel::create_from_fd(stdin_);
>> ioch_out_=Glib::IOChannel::create_from_fd(stdout_);
>> ioch_err_=Glib::IOChannel::create_from_fd(stderr_);
>> #endif
>> }
>>
>> Glib::IOStatus ProcessHandler::read_line_from_out(Glib::ustring& str)
>> {
>> try {
>> return ioch_out_->read_line(str);
>> } catch (Glib::IOChannelError& ex) {...}
>> } catch (Glib::ConvertError& ex) {...}
>> } catch (Glib::Error& ex) {...}
>> } catch (...) {...}
>>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]