0% found this document useful (0 votes)
267 views4 pages

Understanding Text File Formats

A text file is a type of computer file that contains text content as opposed to binary content. It is structured as a sequence of lines made up of text characters. Different operating systems use different conventions for line endings in text files. Text files can be easily viewed and edited on simple text editors and terminals. They avoid some issues that can occur with other file formats like endianness and support recovery from some data corruption. However, they also have lower data compression than some binary formats. The article then discusses specific conventions and formats used for text files on Windows, Unix-like, and classic Mac OS systems.

Uploaded by

James
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
267 views4 pages

Understanding Text File Formats

A text file is a type of computer file that contains text content as opposed to binary content. It is structured as a sequence of lines made up of text characters. Different operating systems use different conventions for line endings in text files. Text files can be easily viewed and edited on simple text editors and terminals. They avoid some issues that can occur with other file formats like endianness and support recovery from some data corruption. However, they also have lower data compression than some binary formats. The article then discusses specific conventions and formats used for text files on Windows, Unix-like, and classic Mac OS systems.

Uploaded by

James
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

From Wikipedia, the free encyclopedia

Jump to: navigation, search


For texting language, see SMS language.

This article needs additional citations for verification. Please help improve t
his article by adding citations to reliable sources. Unsourced material may be c
hallenged and removed. (December 2015)

A common type of icon used to represent text files in a file explorer.


A text file (sometimes spelled "textfile": an old alternative name is "flatfile"
) is a kind of computer file that is structured as a sequence of lines of electr
onic text. A text file exists within a computer file system. The end of a text f
ile is often denoted by placing one or more special characters, known as an endof-file marker, after the last line in a text file. However, on some popular ope
rating systems such as Windows or Linux, text files do not contain any special E
OF character.
"Text file" refers to a type of container, while plain text refers to a type of
content. Text files can contain plain text, but they are not limited to such.
At a generic level of description, there are two kinds of computer files: text f
iles and binary files.[1]

Contents [hide]
1 Data storage
2 Encoding
3 Formats 3.1 Windows text files
3.2 Unix text files
3.3 Apple Macintosh text files
4
5
6
7

Rendering
See also
Notes and references
External links

Data storage[edit]

A stylized iconic depiction of a CSV-formatted text file.


Because of their simplicity, text files are commonly used for storage of informa

tion. They avoid some of the problems encountered with other file formats, such
as endianness, padding bytes, or differences in the number of bytes in a machine
word. Further, when data corruption occurs in a text file, it is often easier t
o recover and continue processing the remaining contents. A disadvantage of text
files is that they usually have a low entropy, meaning that the information occ
upies more storage than is strictly necessary.
A simple text file needs no additional metadata to assist the reader in interpre
tation, and therefore may contain no data at all, which is a case of zero byte f
ile.
Encoding[edit]
The ASCII character set is the most common format for English-language text file
s, and is generally assumed to be the default file format in many situations. Fo
r accented and other non-ASCII characters, it is necessary to choose a character
encoding. In many systems, this is chosen on the basis of the default locale se
tting on the computer it is read on. Common character encodings include ISO 8859
-1 for many European languages.
Because many encodings have only a limited repertoire of characters, they are of
ten only usable to represent text in a limited subset of human languages. Unicod
e is an attempt to create a common standard for representing all known languages
, and most known character sets are subsets of the very large Unicode character
set. Although there are multiple character encodings available for Unicode, the
most common is UTF-8, which has the advantage of being backwards-compatible with
ASCII; that is, every ASCII text file is also a UTF-8 text file with identical
meaning.
Formats[edit]
On most operating systems the name text file refers to file format that allows o
nly plain text content with very little formatting (e.g., no bold or italic type
s). Such files can be viewed and edited on text terminals or in simple text edit
ors. Text files usually have the MIME type "text/plain", usually with additional
information indicating an encoding.
Windows text files[edit]
MS-DOS and Windows use a common text file format, with each line of text separat
ed by a two-character combination: carriage return (CR) and line feed (LF). It i
s common for the last line of text not to be terminated with a CR-LF marker, and
many text editors (including Notepad) do not automatically insert one on the la
st line.
On Microsoft Windows operating systems, a file is regarded as a text file if the
suffix of the name of the file (the "filename extension") is "txt". However, ma
ny other suffixes are used for text files with specific purposes. For example, s
ource code for computer programs is usually kept in text files that have file na
me suffixes indicating the programming language in which the source is written.
Most Windows text files use "ANSI", "OEM", "Unicode" or "UTF-8" encoding. What W
indows terminology calls "ANSI encodings" are usually single-byte ISO-8859 encod
ings (i.e. ANSI in the Microsoft Notepad menus is really "System Code Page", non
-Unicode, legacy encoding), except for in locales such as Chinese, Japanese and
Korean that require double-byte character sets. ANSI encodings were traditionall
y used as default system locales within Windows, before the transition to Unicod
e. By contrast, OEM encodings, also known as MS-DOS code pages, were defined by
IBM for use in the original IBM PC text mode display system. They typically incl
ude graphical and line-drawing characters common in (possibly full-screen) MS-DO

S applications. "Unicode"-encoded Windows text files contain text in UTF-16 Unic


ode Transformation Format. Such files normally begin with Byte Order Mark, which
communicates the endianness of the file content. Although UTF-8 does not suffer
from endianness problems, many Windows programs (i.e. Notepad) prepend the cont
ents of UTF-8-encoded files with Byte Order Mark,[2] to differentiate UTF-8 enco
ding from other 8-bit encodings.[citation needed]
Unix text files[edit]
On Unix-like operating systems text files format is precisely described: POSIX d
efines a text file as a file that contains characters organized into zero or mor
e lines,[3] where lines are sequences of zero or more non-newline characters plu
s a terminating newline character,[4] normally LF.
Additionally, POSIX defines a printable file as a text file whose characters are
printable or space or backspace according to regional rules. This excludes cont
rol characters, which are not printable.[5]
Apple Macintosh text files[edit]
Prior to the advent of Mac OS X, the Mac OS system regarded the content of a fil
e (the data fork) to be a text file when its resource fork indicated that the ty
pe of the file was "TEXT". Lines of Macintosh text files are terminated with CR
characters.
Being certified Unix, Mac OS X uses POSIX format for text files.
Rendering[edit]
When opened by a text editor, human-readable content is presented to the user. T
his often consists of the file's plain text visible to the user. Depending on th
e application, control codes may be rendered either as literal instructions acte
d upon by the editor, or as visible escape characters that can be edited as plai
n text. Though there may be plain text in a text file, control characters within
the file (especially the end-of-file character) can render the plain text unsee
n by a particular method.
See also[edit]
List of file formats
File extensions
ASCII
EBCDIC
Newline
Text editor
Unicode
Notes and references[edit]
[Link] up ^ Lewis, John (2006). Computer Science Illuminated. Jones and Bartlett
. ISBN 0-7637-4149-3.
[Link] up ^ "Using Byte Order Marks". Internationalization for Windows Applicati
ons. Microsoft. Retrieved 2015-12-15.
[Link] up ^ "3.397 Text File". IEEE Std 1003.1, 2013 Edition. IEEE Computer Soci
ety. Retrieved 2015-12-15.
[Link] up ^ "3.206 Line". IEEE Std 1003.1, 2013 Edition. IEEE Computer Society.
Retrieved 2015-12-15.
[Link] up ^ "3.284 Printable File". IEEE Std 1003.1, 2013 Edition. IEEE Computer
Society. Retrieved 2015-12-15.
External links[edit]

C2: the Power of Plain Text


Categories: Text file formats
Computer data

Common questions

Powered by AI

Many text editors on Windows, such as Notepad, do not automatically append an end-of-file marker to the last line of text files, relying on CR-LF for line termination instead. Unix-based systems do not use a specific end-of-file marker either, as they follow the POSIX standard where a newline character, LF, signifies the end of a line. This interoperability allows text files to be opened and edited across different systems without special end-of-file markers .

Windows text files typically use a two-character combination of carriage return (CR) and line feed (LF) to separate lines. Unix-like systems use a single line feed (LF) for line termination, as specified by POSIX. Pre-Mac OS X systems used a single carriage return (CR) to terminate lines in text files. In contrast, Mac OS X, being a Unix-certified system, adopted the POSIX standard using LF for line termination .

The character encoding determines the range of characters that can be represented in a text file. ASCII, being limited in its character repertoire, is suitable only for American English. Encodings like ISO 8859-1 can represent many European languages but are still limited. Unicode, particularly UTF-8 encoding, provides a comprehensive set of characters, enabling text files to represent virtually all human languages. This widespread coverage makes UTF-8 preferable for multilingual text representation .

In Windows, 'ANSI' encodings originally referred to single-byte encodings based on ISO-8859 standards to support characters for Western languages. With the shift towards Unicode, these 'ANSI' encodings became legacy systems often represented in Notepad menus as "System Code Page." 'OEM' encodings were used initially for MS-DOS applications, supporting graphical characters on the original IBM PCs. As computing evolved, Windows transitioned to Unicode, enabling broader language support and resolving compatibility issues inherent in local and OEM encodings .

Text files, by not including complex formatting or binary data, avoid issues like endianness and padding bytes, making them easily interpretable across various platforms. This simplicity allows them to be read and edited on different operating systems with basic text editors, reducing the likelihood of compatibility issues. As data may consist of plain text characters, the risk of corruption is minimized, supporting diverse applications like scripting, configuration, and documentation across systems .

Unicode's backward compatibility with ASCII means that ASCII text files are inherently valid UTF-8 files without altering their meaning. This compatibility simplifies the management and migration of older ASCII files into modern systems that predominantly use UTF-8. It ensures consistency and stability across systems, reducing the potential for misinterpretation or data corruption during file sharing and processing .

Control characters, such as newline and carriage return, influence the presentation of text within editors by defining line breaks and formatting decisions. However, these characters can also make plain text invisible or manipulate content display if misinteracted with by the editor. This can be problematic in sending commands or instructions inadvertently, potentially causing disruptions in reading and editing tasks .

A Byte Order Mark (BOM) in Unicode-encoded Windows text files indicates the endianness of the file content. Specifically, in UTF-16 encoded files, the BOM helps to determine whether the text is stored in big-endian or little-endian order. Although UTF-8 does not face endianness issues, Windows utilities like Notepad use BOM to distinguish UTF-8 encoded files from other 8-bit encodings, enhancing compatibility .

Zero byte files contain no data and no metadata to aid interpretation, making them unique cases in text file management. They can arise from errors in file writing processes or intentional creation for signaling purposes. Their presence can indicate issues in file handling systems or serve as placeholders in directory structures without consuming significant storage, providing useful signals in automated workflows .

Text files are preferred for their simplicity and human-readability, which facilitates easy data recovery and manipulation in case of corruption. Unlike binary files, text files do not encounter issues like endianness or padding. Their plain structure makes them compatible across different systems, which is beneficial for communication and data sharing .

You might also like