|
2023-03-22
| ||
| 12:35 | Merge trunk: Fix [d19fe0a5b]: Handling incomplete byte sequences for utf-16/utf-32. check-in: 1ffd734d41 user: pooryorick tags: unchained | |
|
2023-02-23
| ||
| 11:17 | • Closed ticket [d19fe0a5bf]: Handling incomplete byte sequences for utf-16/utf-32... artifact: 679f46fa6a user: jan.nijtmans | |
| 10:44 | See [d19fe0a5b] for follow-up to previous commit check-in: 548b08e28b user: jan.nijtmans tags: core-8-6-branch | |
|
2023-02-22
| ||
| 17:34 | Fix [d19fe0a5b]: Handling incomplete byte sequences for utf-16/utf-32 check-in: ff5920ffd7 user: jan.nijtmans tags: core-8-6-branch | |
|
2023-02-21
| ||
| 17:52 | • Ticket [d19fe0a5bf] Handling incomplete byte sequences for utf-16/utf-32 sta... artifact: 18c78c5ffc user: jan.nijtmans | |
| 17:50 | Proposed fix for [d19fe0a5b]: Handling incomplete byte sequences for utf-16/utf-32 closed check-in: be99e0b905 user: jan.nijtmans tags: bug-d19fe0a5b | |
| 16:22 | • Ticket [d19fe0a5bf] Handling incomplete byte sequences for utf-16/utf-32 sta... artifact: c4f3dda2af user: jan.nijtmans | |
| 15:59 | • Ticket [d19fe0a5bf]: 3 changes artifact: 798c1f2614 user: apnadkarni | |
| 08:36 | • New ticket [d19fe0a5bf]. artifact: 3ecf8689e1 user: jan.nijtmans | |
Handling incomplete byte sequences for utf-16/utf-32
% encoding convertfrom utf-16le \x41\x00\x41 A
In Tcl 8.7, we see what's happening when using -strict
% encoding convertfrom -strict utf-16le \x41\x00\x00 unexpected byte sequence starting at index 2: '\x0'
But in Tcl 8.6 we don't have -strict, and the byte is silently ignored. That's not good.
Many encodings either output the remaining bytes as-is or the replacement character \xFFFD. For UTF-16/32 outputting the remaining bytes (which easily could be \x00) doesn't make much sense. So most logical would be to output the replacement character in this case (just one).
I had noticed that in my test scripts and adjusted tests accordingly! The premise being that 8.6 was the "gold standard" for 8.x and -profile tcl8 would match that exactly. /Ashok
I known that 8.6 is the "gold standard", but in this case the 8.6 behavior is not reasonable at all. We could discuss whether \xFFFD or '?' should be output. So, when there is doubt, keep it as-is. I have no doubt that \xFFFD is the 'right' thing to do here.
In this case, silently removing bytes is not described anywhere in the documentation, and no other encoder/decoder does that. So it's 100% defendable that this is a bug in 8.6. Bugs can be fixed, always.
Thanks for noticing this!
Proposed fix [here]. Of course, Tcl 8.6 doesn't have utf-16* and utf-32*, it only has "unicode"
Follow-up [here]
When this fix was merged forward, it turned out that Tcl 8.7 only produces TCL_CONVERT_SYNTAX in -strict mode here. Which doesn't exist in 8.6. Therefore - in Tcl 8.6 - we should always produce \xFFFD in this case for maximum consistancy between Tcl versions.
So, in Tcl 8.6 now:
$ tclsh8.6 % encoding convertfrom unicode \x41\x41\x41 䅁�