lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


CRLF end of lines have an origin that comes long before Microsoft (in MSDOS, later Windows, but as well early proprietary versions of Unix made by Microsoft), which just initially used the convention requested and used by IBM and promoted in old standards which which it remained compatible. It dates even before Linux and many Unixes and ad well before Apple's decision to use CR-only newlines.

Those standards are still active and used today. The LF-only convention was a creation on early Unixes and they were proprietary as well when they were introduced to create the C language and *its* initial 'standard' library.
Today, these 3 encodings are endorsed in the standard C library, for which a "text mode" was defined and standardized, and it is formalized in Unicode as well (with a few other encodings whose origin comes also from older IBM standards and EBCDIC, with its use of "C1" controls "LS" and "PS"), and in W3C document formats.

ITU and IETF's BCP's (like MIME) have alway used CRLF as a line terminator as the only conforming convention (which was tentatively extended to allow some freedom, but this never reached the level of becoming used everywhere).
We all have to live with legacy older standards with which we have to remain compatible.

There's been a long life before C, Unix, US-ASCII and the UCS for ISO 10646 and Unicode. Let's not forget it. and note that even Windows no longer requires CRLF newline encodings: the Unicode definition has clarified all this, in full agreement with today's C standard which is independant of Unix/Linux.




Le jeu. 24 mars 2022 à 15:35, Flyer31 Test <flyer31@googlemail.com> a écrit :
Hi Thijs,
though Lua novice, I think this is quite typical problem with text
file, which you really unfortunately have in ANY programming language
/ programming application.

How should "poor Lua" know, whether you are running it on a Windows
(by MS standard using \r\n)  or a Linux system (by standard using \n).

In this same problem you also run, if you use hyperterminal or
teraterm or other programs for serial communications: Some of these
programs will use either the one line end "by standard", and others
the other... .

In my IoT Lua for controllers, I made it like this, that I generally
require \n for line end. If then last char is \r, I will also "kill
this automatically"... but I am NOT sure whether this is "fail proof"
/ at least not in "big system Windows/Linux world" ... possibly some
people would have files with "mixed line end" due to some reasons and
then would prefer to recognize this somehow / handle the \r separately
in Lua.

... on of the "nerving inventions of MS" I always thought ... but if
Mac has the same problem ...  :(.

Another clearly "nerfing invetions of MS" concerning text files, is
the "regional settings dependency" of CSV column / number formatting
(list delimiter char and decimal sep char...).

On Thu, Mar 24, 2022 at 2:51 PM Thijs Schreijer <thijs@thijsschreijer.nl> wrote:
>
>