std.file.readText() extra Line Feed character

ketmar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Dec 19 04:09:12 PST 2014


On Fri, 19 Dec 2014 10:22:01 +0000
Colin via Digitalmars-d-learn <digitalmars-d-learn at puremagic.com> wrote:

> On Thursday, 18 December 2014 at 22:29:30 UTC, Ali Çehreli wrote:
> > On 12/18/2014 02:51 AM, Colin wrote:
> >
> > > > vi, and it does indeed have a '\n' at the end of file.
> > >
> > > Ah, I see. That's a little annoying.
> >
> > It looks like there are ways of dealing with it:
> >
> >
> > http://stackoverflow.com/questions/1050640/vim-disable-automatic-newline-at-end-of-file
> >
> > Ali
> > "happy with Emacs :p"
> 
> Does emacs do this aswell? :)
> 
> Anyway, I'm making a tool which will be in use by a range of
> people, so making the tool accept inputs with \n or not would be
> the better choice than getting everyone to ensure they dont have
> \n at the end of every file.
`.strip` the read string. or just `.stripRight`. this will remove all
unnecessary whitespace noise at both sides of string (`.strip`) or only
at the end of the string (`.stripRight`).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20141219/58e80470/attachment.sig>


More information about the Digitalmars-d-learn mailing list