caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Dmitry Bely <dmitry.bely@gmail.com>
To: Paul Steckler <Paul.Steckler@nicta.com.au>
Cc: "caml-list@yquem.inria.fr" <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] 8-bit characters on command line
Date: Fri, 14 May 2010 09:44:01 +0400	[thread overview]
Message-ID: <AANLkTilI-KpQjYxOlDPFi-E5bvnmusdNK-MSHfJ9-ktJ@mail.gmail.com> (raw)
In-Reply-To: <2EB36A07AAE8C44BBB1986425E7A22D00FA659E379@atp-mbx1.in.nicta.com.au>

On Fri, May 14, 2010 at 8:36 AM, Paul Steckler
<Paul.Steckler@nicta.com.au> wrote:
> I have an OCaml 3.11 program that prints out the arguments on the command line:
>
>  let main =Array.iter (Printf.printf "arg = %s\n") Sys.argv
>
> On Linux, if I provide a command line argument containing 8-bit characters,
> like é (an e with an acute accent), the program above, compiled with ocamlopt
> or ocamlc, prints them faithfully.
>
> For Windows, I can compile the program above with ocamlc on Windows, or cross-compile
> it with MinGW-ocaml on Linux.  In both cases, any 8-bit characters in the command
> line are printed as garbage.  I've tried running the program from rxvt (a shell for
> Cygwin) and Windows cmd.exe.

I believe that's because there are actually two current code pages in
Windows: "OEM" code page for console input/output and "ANSI" one for
everything else. In mode detail:

http://msdn.microsoft.com/en-us/library/dd317752%28VS.85%29.aspx

E.g. in my system ANSI/OEM code pages are 1251/866. In your case they
are probably 1252/437.

Program arguments and any 8-bit character strings inside an
application are considered to have ANSI encoding (as that's what
non-Unicode Windows API functions expect), but console output
functions perform ANSI->OEM code page translation. So you see a
garbage.

- Dmitry Bely


  reply	other threads:[~2010-05-14  5:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-14  4:36 Paul Steckler
2010-05-14  5:44 ` Dmitry Bely [this message]
2010-05-14  6:20   ` [Caml-list] " Paul Steckler
2010-05-14  8:13     ` Dmitry Bely
2010-05-17  2:55       ` Paul Steckler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AANLkTilI-KpQjYxOlDPFi-E5bvnmusdNK-MSHfJ9-ktJ@mail.gmail.com \
    --to=dmitry.bely@gmail.com \
    --cc=Paul.Steckler@nicta.com.au \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).