Nepedia
Back to Discover
Advanced Reader
💻

Text file

technology Maturity 11-13 Next article →

A text file is a specific type of computer file. It is structured as a sequence of lines of electronic text.

Windows Notepad .LOG file
Windows Notepad .LOG file

In the world of computing, files are generally divided into two categories: text files and binary files. While a binary file contains complex data, a text file acts as a simple container for human-readable characters. These files are essential for storing information because of their simplicity. They avoid many technical problems like endianness or differences in machine word sizes. Because they are so straightforward, they are also easier to recover if data corruption occurs.

CsvDelimited001
CsvDelimited001

How a text file is stored depends on the operating system being used. In older systems like CP/M, the computer does not track file size in bytes. Instead, it uses an end-of-file (EOF) marker. This is a special character placed as padding after the last line. Modern systems like Microsoft Windows, DOS, and Unix-like systems do not use EOF characters. They simply keep track of the exact file size in bytes. Some systems, such as OpenVMS or OS/360, use record-oriented filesystems. These store text as a sequence of fixed-length records or variable-length records. In these cases, a record-length value is kept in a record header.

Different operating systems also use different rules for starting new lines. Most systems use an end-of-line delimiter to separate text. DOS and Microsoft Windows use a two-character combination. This combination consists of a carriage return (CR) and a line feed (LF). In Unix-like systems, the standard is a single newline character known as LF. The classic Mac OS used a different method, terminating lines with only a CR character. macOS now follows the Unix format. However, macOS still recognizes older files using specific Uniform Type Identifiers (UTI). These identifiers include "public.plain-text" and "com.apple.traditional-mac-plain-text" for older files.

Encoding is the process of turning digital data into readable characters. The ASCII character set is a very common subset used for English-language files. It covers American English but lacks symbols like the euro sign or the British pound sign. To include these, a richer character set is required. Before the modern era, systems used single-byte encodings like ISO-8859 for European languages. Asian languages often required wide character encodings. Unicode was created to solve this by providing a standard for all known languages.

CsvDelimited001
CsvDelimited001

UTF-8 is the most common encoding for Unicode today. It is backwards-compatible with ASCII, meaning every ASCII file is also a UTF-8 file.

Microsoft Windows uses several different encoding methods for its text files. Many files use ANSI, which refers to single-byte ISO/IEC 8859 encodings. In some regions, like China or Japan, Windows uses double-byte character sets. Another method is OEM encoding, also called DOS code pages. These were defined by IBM for the original IBM PC text mode displays. They often include special characters for drawing lines and shapes. Windows also supports Unicode-encoded files using UTF-16. These files often begin with a byte order mark (BOM). This mark helps the computer understand the endianness, or the order of bytes, in the file.

File names often include a suffix to tell the computer what is inside. On Windows, a text file usually ends with the .txt extension. However, many other suffixes are used for specific purposes. For example, computer programmers keep their source code in text files. These files use suffixes that indicate the specific programming language used. Even though these files contain code, they are still considered text files. A text file can even be empty. This is known as a zero-byte file.

Windows Notepad .LOG file
Windows Notepad .LOG file

Text files can be expanded using lightweight markup languages. Examples include TeX, markdown, and wikitext. These are still considered extensions of plain text because they remain human-readable. They contain small annotations that a computer can interpret. Early versions of HTML also functioned this way, though modern HTML is mostly unreadable by humans. Other formats like CSV, which stands for comma-separated values, are also related.

CsvDelimited001
CsvDelimited001

These allow for organized data in rows and columns while remaining simple and easy to process.

698 words

Where will your curiosity go next?

Keep exploring at your chosen reading level.

🖼️ Images & Media (2)
File:CsvDelimited001.svg
CsvDelimited001.svg
File:Windows Notepad .LOG file.png
Windows Notepad .LOG file.png
More to explore

🔬 Go deeper

More advanced topics to explore

🪜 Step back

Simpler topics to build understanding

What is Nepedia?

A free, ad-free encyclopedia for children. Every article is written at five reading levels, so the same page works for a five-year-old and a fifteen-year-old — use the level switcher above to see this one change. No account needed to read.