D doesn't read the first character of a file (reads everything but the first chararacter) with either read() or readText()

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jul 19 08:18:00 PDT 2017


On 7/17/17 10:21 PM, Enjoys Math wrote:
> 
> DMD32 D Compiler v2.074.1
> 
> import std.file;
> 
> void main() {
>     string bigInput = readText("input.txt");
> }
> 
> The file is 7 MB of ascii text, don't know if that matters...
> 
> Should I upgrade versions?

Looking at the implementation of readText, I believe its implementation 
is not able to trim off the beginning of a file. Be wary of how you look 
at the result, some tools may "helpfully" hide things (like unprintable 
characters, or overwrite what has already been displayed when it sees a 
carriage return).

If you can't figure it out yourself, the best thing to do here is to 
post your exact file somewhere so people can diagnose. Or reproduce with 
a smaller one, and then post that somewhere.

-Steve


More information about the Digitalmars-d-learn mailing list