232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
|
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
|
-
+
-
+
-
+
-
+
|
No changes are required for scripts that were pure ASCII and used
the `\u` or `\U` escapes for non-ASCII characters. Scripts that were
saved using a (non-utf8) system encoding will have to be modified
or sourced using an explicit `-encoding` option.
In TCL8.6, it is anyway good practice to include the `-encoding` parameter to the source command for portability.
A pckIndex.tcl file may look like this:
A pkgIndex.tcl file may look like this:
```
package ifneeded mypackage 1.0 [list source -encoding cp1286 [file join $dir mypackage.tcl]]
package ifneeded mypackage 1.0 [list source -encoding cp1252 [file join $dir mypackage.tcl]]
```
This will still work in 9.0 for any supported codepage.
See [TIP 587](https://core.tcl-lang.org/tips/doc/trunk/tip/587.md).
## Encoding profile *strict* for scripts
The strict encoding profile applies to the source command.
The source command may throw encoding errors.
Scripts with non ASCII characters, even in comments, may now fail if the encoding is wrong.
A typical example is a copyright glyph in a non UTF-8 codepage "©" script file.
In TCL8.6, those errors did not arise, as the active tcl8 profile silently changed those characters to inline iso-8859-1 characters.
If it was real code (like text), the script changed in functionality.
## System encoding on Windows may change to UTF-8
The Windows executable Manifest of tclsh.exe and wish.exe were changed to claim UTF-8 character set.
On my Windows 10 system with German locale, the command *encoding system* returns *utf-8* with TCL/Tk 9.0 and *cp1265* with TCL/Tk 8.6.
On my Windows 10 system with German locale, the command *encoding system* returns *utf-8* with TCL/Tk 9.0 and *cp1252* with TCL/Tk 8.6.
This is due to the manifest change, not any change within TCL/Tk.
Due to that, the change to UTF-8 encoding of the source command may not be *reverted* by:
```
source -encoding [encoding system] file.tcl
```
For me, this is according where Windows is moving.
If I create nowdays a file using the Windows editor application, it is encoded in UTF-8.
With older WIndows versions, this was cp1265.
With older WIndows versions, this was cp1252.
## 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.
|
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
|
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
|
-
+
|
Installers should check for writable locations in any case but this change will
result in errors in installers that write to directories in `auto_path` without
these checks.
## Channel option -eofchar change
Channel option *-eofchar* on write is not supported any more.
The default on MS-Windows is now the empty string (like on all other platforms).
The default on MS-Windows for channels is now the empty string (like on all other platforms).
```
% set t [open test.txt w+]
file46a7048
% fconfigure $t -eofchar
% fconfigure $t -eofchar {a b}
bad value for -eofchar: must be non-NUL ASCII character
```
See [TIP 646](https://core.tcl-lang.org/tips/doc/trunk/tip/646.md).
|