Path: csiph.com!weretis.net!feeder8.news.weretis.net!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson 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> References: <87ttyxlpyi.fsf@nosuchdomain.example.com> 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 Paavo Helde 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 */