@kugel- No, the unicode is not related. I lost my temper, for which I apologize.
The detection in the callback pretty easy: it it invoked with a G_IO_IN | G_IO_PRI condition, attempts to read, but immediately receives G_IO_STATUS_AGAIN. Just to be sure, the callback may count these, and react when they reach, say, 200. Their speed seems to be 5..10K/second on my machine, so 200 seems like a safe bet which will not waste any noticeable time.