[Haskell-cafe] Writing binary files?
Fergus Henderson
fjh007 at galois.com
Tue Sep 14 17:00:12 EDT 2004
On 13-Sep-2004, Glynn Clements <glynn.clements at virgin.net> wrote:
>
> However, If you treat them as ISO-8859-* (it doesn't matter which one,
> so long as you're consistent), the Haskell I/O functions will at least
> pass them through unmodified. Consider a trivial "cp" program:
>
> main = do
> [src, dst] <- getArgs
> text <- readFile src
> writeFile dst text
>
> If the assumed encoding is ISO-8859-*, this program will work
> regardless of the filenames which it is passed or the contents of the
> file (modulo the EOL translation on Windows).
And also modulo the control-Z issue on Windows, and the EOL issue
on old Macs.
But "this program will work (modulo <important issue>)"
is just another way of saying "this program won't work".
The program above may be a reasonably way of copying text files,
but it does not work for copying binary files.
--
Fergus J. Henderson | "I have always known that the pursuit
Galois Connections, Inc. | of excellence is a lethal habit"
Phone: +1 503 626 6616 | -- the last words of T. S. Garp.
More information about the Haskell-Cafe
mailing list