and I don't understand this at all. If I say "-encoding
iso8859-1", am I not saying that the data is textual, and that Tcl
should parse it from "iso8859-1" into the internal Unicode as it
reads it?
Looking at the TCL sources for 9.0 and 8.6, it seems that the
'binary' encoding always has been an alias for 'iso8859-1', which has finally been removed in TCL 9, cf. changes.md:
## Notable incompatibilities
- Removed the encoding alias `binary` to `iso8859-1`.
Effectively nothing should have changed, except you can no longer
say
chan -encoding binary
in tcl 9 (should have used "-translation binary" anyway).
* 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'
Keeping the external "binary" alias visible would have been the better
option in my opinion. Even if it was nothing more than an alias for iso8859-1.
Sysop: | DaiTengu |
---|---|
Location: | Appleton, WI |
Users: | 1,064 |
Nodes: | 10 (0 / 10) |
Uptime: | 170:42:52 |
Calls: | 13,692 |
Files: | 186,936 |
D/L today: |
100 files (20,246K bytes) |
Messages: | 2,411,676 |