D doesn't read the first character of a file (reads everything but the first chararacter) with either read() or readText()
bauss via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Jul 19 19:52:27 PDT 2017
On Wednesday, 19 July 2017 at 15:18:00 UTC, Steven Schveighoffer
wrote:
> 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
I'm feeling this. My keyboard sometimes messes up and will send
invalid key presses to my OS which often ends up with invalid
characters being written in files.
When I encounter it I usually open Notepad++ and turn on show all
characters which will display unprintable characters, simply
allowing me to delete them and have a clean file again.
More information about the Digitalmars-d-learn
mailing list