Sujet : Re: Tcl 8.6 vs 9.0 encoding plus some general confusion
De : ralfixx (at) *nospam* gmx.de (Ralf Fassel)
Groupes : comp.lang.tclDate : 23. Jun 2025, 17:35:26
Autres entêtes
Message-ID : <ygams9ya01d.fsf@akutech.de>
References : 1 2 3
User-Agent : Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
* 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.htmlOn 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'