[Haskell-cafe] Umlauts in command line arguments
Bulat Ziganshin
bulat.ziganshin at gmail.com
Mon Jun 1 04:02:00 EDT 2009
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 at gmail.com
More information about the Haskell-Cafe
mailing list