Umlauts in command line arguments

Hi all, When a command line argument contains an umlaut that argument gets garbled. I'm using ghc 6.10.2 on Win XP. Are there any known solutions for this problem? Günther

On Sun, May 31, 2009 at 8:24 PM, GüŸnther Schmidt
Hi all,
When a command line argument contains an umlaut that argument gets garbled.
I'm using ghc 6.10.2 on Win XP. Are there any known solutions for this problem?
Günther
GHC mangles UTF by default. You probably want to use one of the utf8 packages; eg. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/utf8-string or http://hackage.haskell.org/cgi-bin/hackage-scripts/package/utf8-light (Neither of them seems to allow for accessing *arguments* rather than stdin/stdout, but you could probably do something with the encoding/decoding functions.) -- gwern

Hello Gwern, Monday, June 1, 2009, 4:35:25 AM, you wrote:
GHC mangles UTF by default. You probably want to use one of the utf8 packages; eg. http://hackage.haskell.org/cgi-bin/hackage-scripts/package/utf8-string or http://hackage.haskell.org/cgi-bin/hackage-scripts/package/utf8-light
(Neither of them seems to allow for accessing *arguments* rather than stdin/stdout, but you could probably do something with the encoding/decoding functions.)
in order to get proper unicode handling, one should ask win api directly for cmdline: myGetArgs = do alloca $ \p_argc -> do p_argv_w <- commandLineToArgvW getCommandLineW p_argc argc <- peek p_argc argv_w <- peekArray (i argc) p_argv_w mapM peekTString argv_w >>== tail foreign import stdcall unsafe "windows.h GetCommandLineW" getCommandLineW :: LPTSTR foreign import stdcall unsafe "windows.h CommandLineToArgvW" commandLineToArgvW :: LPCWSTR -> Ptr CInt -> IO (Ptr LPWSTR) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

Hello,
On Sun, May 31, 2009 at 5:24 PM, GüŸnther Schmidt
When a command line argument contains an umlaut that argument gets garbled.
I'm using ghc 6.10.2 on Win XP. Are there any known solutions for this problem?
Your question has inspired me to add a System.Environment.UTF8 module to utf8-string 0.3.5 This module behaves like the System.IO.UTF8 wrapper. -- Eric Mertens

Hello Eric, Friday, June 5, 2009, 12:17:42 AM, you wrote:
I'm using ghc 6.10.2 on Win XP. Are there any known solutions for this problem?
Your question has inspired me to add a System.Environment.UTF8 module to utf8-string 0.3.5
This module behaves like the System.IO.UTF8 wrapper.
it is useless on Windows, since it passes cmdline in ANSI code page rather than UTF-8. proper windows solution is using *W version of WIN API function to get UTF-16 string and then decode it -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com
participants (4)
-
Bulat Ziganshin
-
Eric Mertens
-
Gwern Branwen
-
Günther Schmidt