Skip to content
Tcl Source Code Changes To Migrating scripts to Tcl 9
Login

Changes To Migrating scripts to Tcl 9

Changes to "Migrating scripts to Tcl 9" between 2024-06-19 09:38:55 and 2024-07-29 11:09:12

︙
292
293
294
295
296
297
298












299
300
301
302
303
304
305
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317







+
+
+
+
+
+
+
+
+
+
+
+







set tclName cp[format %u $winCodePage]
if {$tclName in [encoding names]} {
    fconfigure $chan -encoding $tclName
} else {
    ...try some other method...
}
```

## Removal of `binary` and the empty string as valid values for the `-encoding` setting for channels

In Tcl 8.6, `binary` or the empty string could be passed as a valid option to the
`chan configure` and `fconfigure` commands. These are no longer valid in Tcl 9. Pass
`iso8859-1` as the encoding value for the same effect. See the TIP for the rationale.
To configure a channel for binary data, either `open` must be passed the `b` modifier
(e.g. `open foo.txt rb`) or the channel must be configured with `-translation binary`.
This was the case in Tcl 8.6 as well and most uses of `-encoding binary` for the
purpose were either redundant or incorrect.

See [TIP 699](https://core.tcl-lang.org/tips/doc/trunk/tip/699.md).

## Full Unicode support

In Tcl 8, characters outside the BMP were stored as a surrogate pair
and effectively treated as a string of length 2. This is no longer
the case in Tcl 9 which has full support for the entire Unicode range
and will (correctly) treat these characters as strings of length 1.
︙