Files: binary-mode and text-mode

The binary-mode or text-mode keywords affect the automatic processing of newlines in the file being read. When you specify the mode binary-mode, no processing is performed on the newlines. When you specify the mode text-mode, the following sequences are translated to a single newline (ASCII 10) character:

  • carriage return followed by a newline ("%13#%10#")
  • carriage return alone ("%13#")
  • newline alone ("%10#")

For example, if foo were a global or local stream variable, you might issue the following code:

    open foo with (buffered and text-mode) as file "foo.txt"

When neither mode is specified, on a UNIX system, the file is treated as a binary-mode file. (On UNIX systems, the newline (ASCII 10) character is the system-specific newline sequence, so no transformation is necessary for text files.) On all non-UNIX systems, the file is treated as a text-mode file.

Prerequisite Concepts
Related Topics