Alex Jacobson writes:
> 1. Generating GIFs
> I need to create a CGI script that returns a GIF. The docs are somewhat
> unclear about how to do this.
>
> All the IO operators seem to be about Chars and claim to be unicode.
> If they are unicode, does that mean they read 2 bytes at a time of the
> input stream?
>
> Is there a way to maintain the integrity of binary data?
The York nhc13 compiler has a Binary library which will allow you to read
and write arbitrary numbers of bits (up to 32 at a time) to/from files.
putBits :: BinHandle -> Int -> Int -> IO (BinPtr a)
getBits :: BinHandle -> Int -> IO Int
The second argument of each function is the number of bits to transfer.
By the way, in a discussion earlier this week between the implementors
of ghc and of the nhc13 library, we agreed a new high-level interface
to the Binary I/O stuff. Essentially the low-level functions such as
'getBits' will remain the same, but there will be a new layer of
secure typed I/O on top. This means you can expect to see an
implementation of Binary in ghc/Hugs at some point in the future, and
likewise you can expect nhc13's Binary library to grow soon too.
York nhc13 is currently available in beta-release from
http://www.cs.york.ac.uk/fp/nhc13/
Please note that because parts of the Binary library are still in flux,
and there may be small changes and additions from one beta release to
the next. Having said that, the basic library functions are now pretty
stable.
Regards,
Malcolm