Windows console is broken

Janice Caron caron800 at googlemail.com
Thu Jan 31 09:58:16 PST 2008


On 1/31/08, Sergey Gromov <snake.scaly at gmail.com> wrote:
> >example ÜÐÜÐ ßÐßÐ
> Number of arguments to main: 1
>
> >example mother father
> Number of arguments to main: 3
>
> You can do nothing about arguments which are not there.

Wow! That's an interesting problem.

The way I see it is this. main's argument has type string[], and
string is /by definition/ UTF-8, so D is not wrong to reject non-UTF-8
input. The problem is that the console is feeding it with non-UTF
data.

So there would be two possible fixes. Either (1), allow main to have a signature

    main(ubyte[][] args)

thereby allowing any encoding, or (2) have the D runtime convert the
shell arguments from the console's local encoding to UTF-8 before
passing to main.

I think I would prefer a combination of both. That is, if
main(ubyte[][]) exists, call that; else transcode the input then call
main(string[]). That gets you the best of both worlds (but you still
have the same problem with output).




More information about the Digitalmars-d mailing list