[Haskell-cafe] How to get program command line arguments in
Unicode-aware way (Unix/Linux)?
golubovsky at gmail.com
Wed Mar 11 22:42:14 EDT 2009
I am trying to process command line arguments that may contain Unicode
(cyrillic in this example) characters.
The standard GHC's getArgs seems to pass whatever was obtained from
the underlying C library
without any regard to encoding, e. g the following program (testarg.hs):
module Main where
main = do
x <- getArgs
mapM (putStrLn . show) x
being invoked (ghc 6.10.1)
runghc testarg -T 'при<в>ет'
prints the following:
(not correct, all bytes were passed without proper encoding)
Is there any way to get program arguments in GHC Unicode-aware? Or at
least assuming that they are always in UTF-8?
Something like System.IO.UTF8, but for command line arguments?
PS: BTW runhugs testarg -T 'при<в>ет' prints:
which is correct.
Anywhere on the Web
More information about the Haskell-Cafe