Skip to content
Tcl Source Code Changes To Migrating C extensions to Tcl 9
Login

Changes To Migrating C extensions to Tcl 9

Changes to "Migrating C extensions to Tcl 9" between 2023-11-08 17:23:32 and 2023-11-15 08:31:37

︙
60
61
62
63
64
65
66
67

68


















69





70
71
72
73
74
75
76
60
61
62
63
64
65
66

67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99







-
+

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

+
+
+
+
+








```

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

## Unicode support

32-bit Tcl_UniChar, profiles...
### `Tcl_UniChar` and `TCL_UTF_MAX`

As part of the changes to support the full range of Unicode code points, the
`Tcl_UniChar` type has changed to a 32-bit integer type. Correspondingly, the
default value of `TCL_UTF_MAX` is now 4.

This means that encoding API's such as `Tcl_GetUnicodeFromObj` that work with
`Tcl_UniChar` strings can no longer be used to pass values to external API's
that expect UTF-16 encoded strings. This is particularly relevant on Windows
platforms where it was common in Tcl 8 to use these functions to transform
strings to the UTF-16 / UCS-2 form expected by the Win32 API. Instead, use either

* 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.

### Profiles

TBD

### Strict encoding

TBD 


## `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).

︙