The value associated with -translation is a single item for
read-only and write-only channels.
The value is a two-element list for read-write channels;
the read translation mode is the first element of the list,
and the write translation mode is the second element.
As a convenience, when setting the translation mode for a read-write channel
you can specify a single value that will apply to both reading and writing.
When querying the translation mode of a read-write channel,
a two-element list will always be returned.
The following values are currently supported:
-
auto
-
As the input translation mode, auto treats any of newline (lf),
carriage return (cr), or carriage return followed by a newline (crlf)
as the end of line representation. The end of line representation can
even change from line-to-line, and all cases are translated to a newline.
As the output translation mode, auto chooses a platform specific
representation; for sockets on all platforms Tcl
chooses crlf, for all Unix flavors, it chooses lf, for the
Macintosh platform it chooses cr and for the various flavors of
Windows it chooses crlf.
The default setting for -translation is auto for both
input and output.
-
binary
-
No end-of-line translations are performed. This is nearly identical to
lf mode, except that in addition binary mode also sets the
end of file character to the empty string, which disables it.
See the description of
-eofchar for more information.
-
cr
-
The end of a line in the underlying file or device is represented
by a single carriage return character.
As the input translation mode, cr mode converts carriage returns
to newline characters.
As the output translation mode, cr mode
translates newline characters to carriage returns.
This mode is typically used on Macintosh platforms.
-
crlf
-
The end of a line in the underlying file or device is represented
by a carriage return character followed by a linefeed character.
As the input translation mode, crlf mode converts
carriage-return-linefeed sequences
to newline characters.
As the output translation mode, crlf mode
translates newline characters to
carriage-return-linefeed sequences.
This mode is typically used on Windows platforms and for network
connections.
-
lf
-
The end of a line in the underlying file or device is represented
by a single newline (linefeed) character.
In this mode no translations occur during either input or output.
This mode is typically used on UNIX platforms.