[Haskell-cafe] Re: Unicode workaround for getDirectoryContents under Windows?

Bulat Ziganshin bulat.ziganshin at gmail.com
Tue Jun 16 16:19:45 EDT 2009

Hello Simon,

Tuesday, June 16, 2009, 5:02:43 PM, you wrote:

> I don't know how getArgs fits in here - should we be decoding argv using
> the ACP?

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 >>= return.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