| re: Q: std::getline and portability
llewelly <llewelly.at@xmission.dot.com> writes:
[color=blue]
> Frank Schmitt <frank.schmitt@4sc.com> writes:
>[color=green]
> > Hi!
> >
> > I've just been bitten by the famous Windows newline issue, i.e.
> > tried to read a textfile written by a windows application on
> > an unix platform. When reading a line with
> >
> > std::getline(input,buf);
> >
> > GCC 3.2 leaves a trailing '\r' in buf.
> > Is this standard conformant?[/color]
>
> Yes.
>[color=green]
> > My impression was that getline
> > should remove '\r\n' as well as '\n'.[/color]
>
> Not on unix. On unix \n is just LF, so that is all that is
> removed. The CR windows put there is not part of a unix newline,
> and is left alone. If you want it removed you must do so
> yourself.[/color]
Ah, I feared so.
Thanks to all for the quick & informative answers
frank
--
Frank Schmitt
4SC AG phone: +49 89 700763-0
e-mail: frank DOT schmitt AT 4sc DOT com |