[Haskell-cafe] Strange console IO behavior (at least on Windows)
dagit at codersbase.com
Sat Aug 22 17:36:14 EDT 2009
On Sat, Aug 22, 2009 at 2:14 PM, Peter Verswyvelen<bugfact at gmail.com> wrote:
> The following program
> 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?
For me on OSX it has the intended behavior. Which is to say, every
time I type a key I see the ascii value of the key. I have no idea
why windows is being different.
More information about the Haskell-Cafe