std.file.read || writefln

Markus Dangl danglm at in.tum.de
Sat Jun 17 05:56:29 PDT 2006


Jarrett Billingsley schrieb:
> "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 ;) 

This is a bad example, i corrected it. Using writefln for binary data 
isn't a thing you want to do normally ;)



More information about the Digitalmars-d-learn mailing list