1
2
3
4
5
6
7
8
9
|
1
2
3
4
5
6
7
8
9
10
11
12
|
+
+
+
|
(Work in progress...)
Also see [Porting extensions to Tcl 9](https://wiki.tcl-lang.org/page/Porting+extensions+to+Tcl+9)
for another post on the topic.
## 64-bit data support
On 64-bit platforms, Tcl 9 no longer limits data size (lengths of strings, lists
etc.) and indices to 32-bits. For portability of extensions between 32- and
64-bit platforms, a new typedef `Tcl_Size` has been defined. This maps to a
64-bit or 32-bit signed integer type on the respective platforms. This affects
all public structures and parameter types as appropriate. Variables that hold
|
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
+
-
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
|
* the UTF-16 specific `Tcl_Char16ToUtfDString`, `Tcl_UtfToChar16DString`,
`Tcl_UtfToChar16` functions, or
* the generic functions `Tcl_UtfToExternalDStringEx`, `Tcl_ExternaltoUtfDStringEx`,
`Tcl_UtfToExternal`, `Tcl_ExternalToUtf` with the `utf-16` encoding.
### Encoding transforms
### Profiles
Tcl 9 supports *encoding profiles* that allow control of how errors are handled
in encoding transforms. At the C API level, profiles are passed by or-ing one of
the `TCL_PROFILE_*` values as part of the `flags` parameter to encoding
transform functions like `Tcl_ExternalToUtf` and `Tcl_UtfToExternal`.
Extensions that or-ed `TCL_ENCODING_STOPONERROR` in the `flags` parameter
to these functions in Tcl 8 should now use `TCL_ENCODING_PROFILE_STRICT`
instead or not specify a profile at all as `strict` is the default in any case.
TBD
Extensions that did not make use of `TCL_ENCODING_STOPONERROR` will see
a change in that the functions default to the strict profile and will return
an error on invalid encoding bytes. To revert to Tcl 8 behavior, the
`TCL_ENCODING_PROFILE_TCL8` must be specified. Alternatively,
`TCL_ENCODING_PROFILE_REPLACE` may be used to which is standard-compliant
but does not raise an error on invalid encodings.
See [TIP 656](https://core.tcl-lang.org/tips/doc/trunk/tip/656.md)
### Strict encoding
## Encoding errors on I/O
In Tcl 8, any invalid byte sequence encountered in channel input were silently
handled by treating the invalid bytes as iso8859-1 encoded bytes. Similarly, on
output Tcl replaced characters that could not be represented in the channel
encoding with an encoding-specific replacement character, usually `?`. In
contrast, channel I/O in Tcl 9 is by default subject to the `strict` encoding
profile and the above are treated as error conditions. Functions like
`Tcl_Read`, `Tcl_Gets` etc. on input and `Tcl_Write` etc. on output will raise
an error for these cases.
TBD
Applications and extensions that need to match Tcl 8 behavior for compatibility
reasons can set the `-profile` configuration option for the channel to `tcl8` via
the `Tcl_SetChannelOption` function. This is however non-conformant with the
Unicode standard and is not recommended. A standard-conformant alternative is
to set the profile to `replace` instead.
See [TIP 657](https://core.tcl-lang.org/tips/doc/trunk/tip/657.md)
## `Tcl_ObjType` versioning
The Tcl value system has been extended. The `Tcl_ObjType` has additional (optional) fields. Any Tcl extensions, or embedded integration with Tcl, that has a custom `Tcl_ObjType` value defined, should review these changes. Existing code should compile and execute just fine, unless the particular implementation is using any "creative" programming. In simpler terms, the `Tcl_ObjType` structure is larger. It should be initialized properly without any changes needed, but YMMV.
Please see the `Tcl_RegisterObjType` manual page for more details, as well as TIP's [636](https://core.tcl-lang.org/tips/doc/trunk/tip/636.md) and [644](https://core.tcl-lang.org/tips/doc/trunk/tip/644.md).
|