
On Saturday 15 May 2010 15:18:28, Brandon Simmons wrote:
On May 14, 2010, at 20:24 , Brandon Simmons wrote:
The other baffling thing is this: if the debugging line 426 is uncommented, then even running:
$> runghc Befunge.hs --quiet mycology.b98
...will fail. But all we're doing is a call to `putStr`! Why would that trigger an error?! Maybe there was a bug in my code that was
GHC 6.12's runtime handles input and output encoding, instead of simply truncating Chars; my guess is it's locale-related. And sure enough, I see several non-ASCII characters in mycology.b98 which are likely to do the wrong thing if the runtime doesn't know which character set to use.
Thanks, that makes a lot of sense. Is there something I can read to enlighten myself as to how I would go about getting my program to be liberal about non-ascii characters in a file?
Non-ASCII characters aren't a problem per se. The problem is that by default, GHC reads files as encoded by the system locale. If the file is encoded in a different way - boom. You can set the encoding of a handle, so that the file's contents are interpreted e.g. as latin1 encoded (or cp1252 or utf-16, ...). Or you can iconv your files to your system's locale (probably utf-8).
Also, I noticed yesterday that
$> cabal list --installed
shows the 'old-locale' package:
* old-locale Synopsis: locale library Latest version available: 1.0.0.2 Latest version installed: 1.0.0.2 License: BSD3
I'm not sure if that could be part of the issue, or whether that is normal.
That's normal. old-locale comes with GHC.
Thanks again, Brandon Simmons http://coder.bsimmons.name/