On Thu, 18 Dec 2014 09:18:35 +0000
Colin via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> wrote:

> Why does std.file.readText() append a Line Feed char onto the end 
> of the string?
> 
> I have a file with the following contents in it:
> Name   =               Int
> Other=Float
> One More = String(Random;)
> 
> I then have the code:
> 
> void main(string[] args){
>      const text = "Name   =               Int
> Other=Float
> One More = String(Random;)";
> 
>      string input = readText(args[1]);
> 
>      writefln("Raw data");
>      writefln("D)    %s", cast(ubyte[])text[$-5..$]);
>      writefln("File) %s", cast(ubyte[])input[$-5..$]);
> 
> }
> 
> This produces:
> Raw data
> D)    [100, 111, 109, 59, 41]
> File) [111, 109, 59, 41, 10]
> 
> Any Idea why the reading from the File adds on that extra '10' 
> character?
> 
> I don't think it's my editor adding chars to the end of the file, 
> as I'm using vi.

you *definetely* has the last line ended with '\n'.

Attachment: signature.asc
Description: PGP signature

Reply via email to