How to work around GHC bug
Sergei Trofimovich
slyfox at inbox.ru
Sun Mar 18 22:25:23 CET 2012
On Wed, 14 Mar 2012 14:51:59 +0100
Volker Wysk <pf3 at volker-wysk.de> wrote:
> Hi!
>
> The following program demonstrates a (another) GHC bug. The command line isn't
> properly decoded to Unicode.
>
> arg.hs------------------------------
>
> import System
> main = do
> [a] <- getArgs
> putStrLn (show a)
>
> --------------------------------------
>
> When called like this:
>
> ./arg ä
>
> The program will output this:
>
> "\195\164"
First, no need for 'show'. It will try to serialize value in a portable way.
'putStrLn a' should do the right thing (but see below).
Second, it was fixed in ghc-7.2+. System.Environment now
returns properly encoded Strings instead of byte-encoded oddity
it returned before.
So you can use 'putStrLn a' there. Previous version would require
you to recode the result to proper String
--
Sergei
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/glasgow-haskell-users/attachments/20120319/90590e90/attachment.pgp>
More information about the Glasgow-haskell-users
mailing list