Sujet : Re: Tcl 8.6 vs 9.0 encoding plus some general confusion
De : wortkarg3 (at) *nospam* yahoo.com (Harald Oehlmann)
Groupes : comp.lang.tclDate : 24. Jun 2025, 07:55:21
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <103di4o$1s2ei$1@dont-email.me>
References : 1 2 3 4
User-Agent : Mozilla Thunderbird
Am 23.06.2025 um 18:35 schrieb Ralf Fassel:
* Rich <rich@example.invalid>
| Ralf Fassel <ralfixx@gmx.de> wrote:
| > ## Notable incompatibilities
| > - Removed the encoding alias `binary` to `iso8859-1`.
>
| This feels like unnecesary exposure of internal details that an end
| user is not concerned about.
>
| A user wants to read "binary" data, it would seem that they would
| expect to use "binary" as the name for that "encoding" (well, really, a
| lack of any encoding). If it indeed was mapped to iso8859-1
| internally, that is an internal implemntation detail that is of no
| concern to them.
The tcl-9 manpage is not clear on this topic IMHO:
https://www.tcl-lang.org/man/tcl/TclCmd/chan.html
On the one hand, it states for -encoding:
https://www.tcl-lang.org/man/tcl/TclCmd/chan.html#M11
If a file contains pure binary data (for instance, a JPEG image), the
encoding for the channel should be configured to be iso8859-1. Tcl will
then assign no interpretation to the data in the file and simply read or
write raw bytes.
Two sentences later:
It is usually better to set the -translation option to binary when
you want to transfer binary data, as this turns off the other
automatic interpretations of the bytes in the stream as well.
And for -translation:
https://www.tcl-lang.org/man/tcl/TclCmd/chan.html#M17
binary
Like lf, no end-of-line translation is performed, but in addition,
sets -eofchar to the empty string to disable it, and sets
-encoding to iso8859-1.
This sounds to me that configuring only "-encoding iso8859-1" is *not*
enough to read binary data (since crlf translation and eofchar handling
might still apply), and that the "usually better" should really read
"necessary to".
R'
Yes, "-translation binary" has also the advantage to work on 8.6 and 9.0.