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 2023-11-16 11:55:45 and 2023-11-25 14:23:27

1
2
3
4
5

6





7

























8
9
10
11
12
13
14
1
2
3
4

5
6
7
8
9
10
11

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43




-
+

+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







Work in progress...
Currently focused on incompatibilities. Possibly hints on improving
scripts making use of new facilities could be added at some point

## Strict encoding
## Strict handling of ill-formed encoded data

Conceptually, Tcl strings are a sequence of Unicode code points. These strings
are converted to and from external encodings via channel I/O or explicit use of
the `encoding` command. The behavior of Tcl has changed in Tcl 9 in the presence
of ill-formed encoded data in input streams or if output streams encodings do
not support the Unicode code point being written.
TBD - pending CFV on TIP 657, 653 etc.

In the case of input channels, Tcl 8 would silently map invalid bytes in the
stream to the numerically equivalent Unicode code points, in essence presuming
iso8859-1 encoding. On output streams, characters not supported by the output
encoding were substituted with an encoding-specific replacement character.

In contrast, channels in Tcl 9 are by default configured with the `strict`
encoding profile and will raise an error exception for both the above cases. If
Tcl 8 behavior is desired, applications can use the `-profile` option to
`fconfigure` to apply the `tcl8` encoding profile to the channel. This is not
recommended as it is not standards-compliant and can be seen as corrupting data.
Instead, a standards-compliant alternative is to use the `replace` profile which
like the `tcl8` profile will also not raise errors in the presence of invalidly
encoded data.

The same behavioural changes also apply to explicit transforms with the
`encoding` command. Ill formed data or unsupported characters will result in an
error exception. The `-profile` option can be used in this case as well to
change this behavior.

For more on encoding profiles, refer to the `encoding` manpage.

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



## Tilde substitution

File path arguments in Tcl 8 would be subject to tilde substitution
where `~` and `~USER` prefixes in the path would be replaced with the
home directory of the current or named user respectively. Although
convenient for interactive use, this behavior lead to both security and
︙