Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #89513

Re: why additional \r before each \r\n

Path csiph.com!weretis.net!feeder8.news.weretis.net!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From Keith Thompson <Keith.S.Thompson+u@gmail.com>
Newsgroups comp.lang.c++
Subject Re: why additional \r before each \r\n
Date Tue, 07 Mar 2023 12:17:34 -0800
Organization None to speak of
Lines 28
Message-ID <87ttywqpsx.fsf@nosuchdomain.example.com> (permalink)
References <tu532n$33e16$1@portraits.wsisiz.edu.pl> <k6mhs0FavanU1@mid.individual.net> <tu59ek$33qdu$1@portraits.wsisiz.edu.pl> <87ttyxlpyi.fsf@nosuchdomain.example.com> <tu5f9q$343r9$1@portraits.wsisiz.edu.pl> <tu6ltn$a35r$1@dont-email.me>
MIME-Version 1.0
Content-Type text/plain
Injection-Info reader01.eternal-september.org; posting-host="e87d89631dcfc67f7005336381f5fffb"; logging-data="579877"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+/EWqFwBn15XevtG0aHkQ9"
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock sha1:IGWneWLr/8Y+oTLjMXRtS9tIc2A= sha1:s87P3qaO3zT4gJBFtA8wfUdMz3E=
Xref csiph.com comp.lang.c++:89513

Show key headers only | View raw


Paavo Helde <eesnimi@osa.pri.ee> writes:
> 06.03.2023 20:35 Jivanmukta kirjutas:
[...]
>> You are right. I used macro because I had 2 different definitions
>> for Linux and for Windows. Now I have identical definitions and
>> macro is not necessary.
>
> But you still have different file contents in Windows and in Linux,
> because of the "helpful" translation of line feeds in text mode. This 
> just complicates things and is not needed for anything because
> nowadays the files are commonly shared over the network and can easily
> end up on a "wrong platform".
>
> Suggesting to always use binary mode file streams and '\n' newlines
> when writing files, to get predictable and fixed behavior. Nowadays
> even Notepad copes with the Unix-style newlines, so there should be no
> need to have any \r\n newlines around.

Another approach is to use the native encoding for each operating
system.  Many (but not all) Unix/Linux tools handle files with
Windows-style line endings.

Yes, it can be annoying, but it's workable.

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for XCOM Labs
void Void(void) { Void(); } /* The recursive call of the void */

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

why additional \r before each \r\n Jivanmukta <jivanmukta@poczta.onet.pl> - 2023-03-06 17:06 +0100
  Re: why additional \r before each \r\n Bo Persson <bo@bo-persson.se> - 2023-03-06 17:14 +0100
    Re: why additional \r before each \r\n Bo Persson <bo@bo-persson.se> - 2023-03-06 17:17 +0100
    Re: why additional \r before each \r\n Jivanmukta <jivanmukta@poczta.onet.pl> - 2023-03-06 18:55 +0100
      Re: why additional \r before each \r\n Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-03-06 10:00 -0800
        Re: why additional \r before each \r\n Jivanmukta <jivanmukta@poczta.onet.pl> - 2023-03-06 19:35 +0100
          Re: why additional \r before each \r\n Paavo Helde <eesnimi@osa.pri.ee> - 2023-03-07 08:34 +0200
            Re: why additional \r before each \r\n Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-03-07 12:17 -0800
  Re: why additional \r before each \r\n Jivanmukta <jivanmukta@poczta.onet.pl> - 2023-03-06 17:24 +0100
  Re: why additional \r before each \r\n James Kuyper <jameskuyper@alumni.caltech.edu> - 2023-03-06 14:30 -0500

csiph-web