Consider the lowly text file.
This text file can take on a surprising number of different formats. The text could be encoded as ASCII, UTF-8, UTF-16 (little or big-endian), Windows-1252, Shift JIS, or any of dozens of other encodings. The file may or may not begin with a byte order mark (BOM). Lines of text could be terminated with a linefeed character \n
(typical on UNIX), a CRLF sequence \r\n
(typical on Windows) or, if the file was created on an older system, some other character sequence.
Sometimes it’s impossible to determine the encoding used by a particular text file. For example, suppose a file contains the following bytes: