digitalmars.D.learn - std.file.read || writefln
- MM (7/7) Jun 16 2006 Why do I get:
- Jarrett Billingsley (12/19) Jun 16 2006 That's an interesting bug. Notice the "MZ" at the beginning of your
- MM (4/6) Jun 16 2006 Ay sir, I will as soon as you tell me what the best way to read raw data...
- Derek Parnell (7/15) Jun 16 2006 It wasn't the reading that caused the crash but trying to write the raw ...
- MM (6/12) Jun 17 2006 Somehow my last post got lost... here it is again :)
- Jarrett Billingsley (4/13) Jun 17 2006 Use std.stream.File, or std.stream.BufferedFile. To see if you're at th...
- Markus Dangl (3/30) Jun 17 2006 This is a bad example, i corrected it. Using writefln for binary data
Why do I get: 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)
Jun 16 2006
"MM" <MM_member pathlink.com> wrote in message news:e6v3hk$b1u$1 digitaldaemon.com...Why do I get: 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 ;)
Jun 16 2006
Change it to args[1], and it should work. And update that wiki article while you're at it ;)Ay sir, I will as soon as you tell me what the best way to read raw data is.. from the beginning, byte for byte, till end of file :D (while I'm waiting for my registration email to come to me :) and thx
Jun 16 2006
On Sat, 17 Jun 2006 08:02:49 +1000, MM <MM_member pathlink.com> wrote:It wasn't the reading that caused the crash but trying to write the raw data as if it was char[] (UTF8). You have to treat raw data as ubyte[] or byte[] depending on how you will use it. -- Derek Parnell Melbourne, AustraliaChange it to args[1], and it should work. And update that wiki article while you're at it ;)Ay sir, I will as soon as you tell me what the best way to read raw data is.. from the beginning, byte for byte, till end of file :D (while I'm waiting for my registration email to come to me :) and thx
Jun 16 2006
It wasn't the reading that caused the crash but trying to write the raw data as if it was char[] (UTF8). You have to treat raw data as ubyte[] or byte[] depending on how you will use it. -- Derek Parnell Melbourne, AustraliaSomehow my last post got lost... here it is again :) I wanted to read a file without having to put the whole thing in mem.. Or doen't read do this? If there is some way to read a file byte for byte how do I know end_of_file? (I also didn't recieve the registration email from the docwiki... I'll try that again too, although the problem is already corrected :)
Jun 17 2006
"MM" <MM_member pathlink.com> wrote in message news:e71o47$c4v$1 digitaldaemon.com...Somehow my last post got lost... here it is again :) I wanted to read a file without having to put the whole thing in mem.. Or doen't read do this? If there is some way to read a file byte for byte how do I know end_of_file? (I also didn't recieve the registration email from the docwiki... I'll try that again too, although the problem is already corrected :)Use std.stream.File, or std.stream.BufferedFile. To see if you're at the end of the file, use the .eof() method for either of those.
Jun 17 2006
Jarrett Billingsley schrieb:"MM" <MM_member pathlink.com> wrote in message news:e6v3hk$b1u$1 digitaldaemon.com...This is a bad example, i corrected it. Using writefln for binary data isn't a thing you want to do normally ;)Why do I get: 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 ;)
Jun 17 2006