Re[2]: [Haskell-cafe] Umlauts in command line arguments

2009-06-05 Thread Bulat Ziganshin
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,
 Bulatmailto:bulat.zigans...@gmail.com

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re[2]: [Haskell-cafe] Umlauts in command line arguments

2009-06-01 Thread Bulat Ziganshin
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,
 Bulatmailto:bulat.zigans...@gmail.com

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe