There are different conventions of representing the new line character in different types of OSes.
Does the newline convention have nothing to do with what encoding is used?
Is the newline convention not part of any(most) encoding method (e.g. ASCII, utf8, cp1253, …)?
While the said encodings specify the code for new line
and carriage return
, it is not part of the encoding whether or not you should use both, as is normal in a Windows environment, or just new line
which is normal in a Unix environment.
Also worthy of note is that on Unix, the newline is treated as a sort of “end of line” marker, and thus the last line in the file should also end with a newline. It is not common in Windows applications* to follow this practice, and thus normally text files created by a Windows application do not have an end-of-line marker after the last line.
* unless that application is in fact an application written for a Unix environment, and ported to Windows, e.g. vim.
2
Encoding methods deal with how to represent characters as binary data. For example, the letter “A” has a particular bit sequence that describes it. Unicode defines several methods to translate between code points and their bit representation. Code pages do the same but with only 8 bits. This is the purpose of encoding schemes.
Which newlines are used (CRLF, LF) is completely irrelevant to how those nonprintable characters are represented in a particular encoding.