Text file encodings and formats

The text files on different platforms use different character encodings and end-of-line characters by default. Although most operating systems can handle a wide variety of encodings, each system has a default (often determined by language or localization settings) that will be used if none is specified. Text files on different platforms also use different character codes for end-of-line characters.

The defaults for English versions of major operating systems are shown here:

OS Default Default new line
Windows cp1252 Carriage return + line feed (\r\n)
Linux (most modern distributions) UTF-8 Line feed (\n)
macOS US-ASCII Line feed (\n)

 

Most of the time, these differences do not represent a problem, ...

Get Python GUI Programming with Tkinter now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.