std.file.read || writefln

Jarrett Billingsley kb3ctd2 at yahoo.com
Fri Jun 16 14:00:13 PDT 2006


"MM" <MM_member at pathlink.com> wrote in message 
news:e6v3hk$b1u$1 at digitaldaemon.com...
> Why do I get:
> MZ` &#9786;   &#9830; &#9658;
> An exception occured: 4invalid UTF-8 sequence
>
> From:
> http://www.docwiki.net/view.php?pageid=150
>
> The content of the file doesn't matter afaik :)
> Just some simple .txt file in ansi or unicode.. (windowsxp)

That's an interesting bug.  Notice the "MZ" at the beginning of your 
output - that's the header for an EXE file.  What's going on is that args[0] 
is actually the name of the running program - that is, if you compile this 
program as "test.d", the program will be "test.exe" - so when you type in

test something.txt

On the command line, the args[][] array is populated with:

["test.exe", "something.txt"]

So args[0] is the name of the program.

Change it to args[1], and it should work.  And update that wiki article 
while you're at it ;) 





More information about the Digitalmars-d-learn mailing list