[Haskell-cafe] Strange console IO behavior (at least on Windows)

Peter Verswyvelen bugfact at gmail.com
Sat Aug 22 17:14:00 EDT 2009


The following program
http://hpaste.org/fastcgi/hpaste.fcgi/view?id=8445#a8445

should echo the ASCII code of each character the user types, on the fly,
with no line buffering whatsoever.

But it doesn't. At least not under Windows's cmd, and even less with msys.

Under Windows, I have to press enter before anything is printed to the
screen. It then always prints 71 (that's upper G, no idea where that comes
from), and then blocks. Pressing enter again prints the codes of all
characters typed, except the first one, following by the two codes of the
linefeeds. So e.g. when I type "abc" ENTER, I get 71, then hitting ENTER
again, I get 98 99 10 10.

Under msys, it just ignores both the hSetBuffering and hSetEcho, but when
hitting enter, it at least prints the codes correctly.

How does it behave under OSX and Linux? Is this a bug or am I doing
something wrong?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090822/eeb27ed2/attachment.html


More information about the Haskell-Cafe mailing list