WinHugs bug: putChar (chr 255)
Hello , seems that WinHugs hates to do binary I/O :))) Main> putChar (chr 255) я Program error: <stdout>: Prelude.putChar: does not exist (file does not exist) the same problem in this program: import System.IO import Data.Char main = do h <- openBinaryFile "test" WriteMode hPutChar h (chr 255) hPutChar h 'a' -- never executed -- Best regards, Bulat mailto:bulatz@HotPOP.com
On Mon, Feb 06, 2006 at 12:28:06PM +0000, Neil Mitchell wrote:
In the underlying C API, (char)255 == (char)-1 == EOF. Regards, Malcolm
But I think the underlying C API is actually int, and char 255 is a Unicode char. Anyway, I should be able to make some progress on it in the next few days.
The example works fine under Unix, BTW.
In the underlying C API, (char)255 == (char)-1 == EOF. Regards, Malcolm
But I think the underlying C API is actually int, and char 255 is a Unicode char. Anyway, I should be able to make some progress on it in the next few days.
The example works fine under Unix, BTW.
(Just a WAG, but) Perhaps this is not due to OS but different compiler defaults, because: http://c-faq.com/stdio/getcharc.html "Whether plain char is signed or unsigned is implementation- defined." ( http://www.dreamsongs.com/WorseIsBetter.html leaps suddenly to mind. . . )
Hi,
seems that WinHugs hates to do binary I/O :)))
Main> putChar (chr 255) я Program error: <stdout>: Prelude.putChar: does not exist (file does not exist)
Fixed in the CVS version. Once I've got round to writing a build script, I'll be able to release these fixes quicker as updates. The bug was all to do with char/int conversion, and 255 == -1 at a char level, and Hugs checking for EOF on the result. A few char -> int and it was all fine. Thanks Neil
Hello Neil, Tuesday, February 07, 2006, 3:58:33 PM, you wrote:
Main> putChar (chr 255)
NM> The bug was all to do with char/int conversion, and 255 == -1 at a NM> char level, and Hugs checking for EOF on the result. A few char -> int NM> and it was all fine. we all guess that it the source of problem :) btw, how about reading chr(0) and chr(255)? i don't checked this... -- Best regards, Bulat mailto:bulatz@HotPOP.com
Hi,
we all guess that it the source of problem :) btw, how about reading chr(0) and chr(255)? i don't checked this...
Good point. Just for reference, reading from a file worked fine with both those values. Reading from the "stdin" with 0 is impossible because of the design of WinHugs (there is no way for a user to type a null). Reading 255 didn't work, this has now been fixed. Thanks Neil
participants (5)
-
Bulat Ziganshin -
Malcolm Wallace -
Neil Mitchell -
Robert Praetorius -
Ross Paterson