Windows console is broken

Sean Kelly sean at f4.ca
Thu Jan 31 12:42:48 PST 2008


Janice Caron wrote:
> 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.

Tango does (2) on Windows.  This doesn't appear to be a problem on other
OSes however, because the consoles there can typically be set to use
UTF-8.  As far as I know it's just Windows that's in the stone age.


Sean



More information about the Digitalmars-d mailing list