Different handling of surrogates in utf-8 between Tcl8 and Tcl9
In Tcl 8.7,
% package require Tcl
8.7a6
% codepoints [encoding convertfrom utf-8 [binary decode hex EDAFBFEDBFBF]]
U+10FFFF
In Tcl 9,
% package require Tcl
9.0a4
% codepoints [encoding convertfrom utf-8 [binary decode hex EDAFBFEDBFBF]]
U+00DBFF U+00DFFF
Surrogate pairs are not allowed in strict utf-8 but the above is not strict. In my opinion, the Tcl 8.7 behavior is preferable but since this is non-conformant anyways, either behavior might be ok. But they should be consistent between Tcl 8 and 9.
This change is explained in TIP #619:
https://core.tcl-lang.org/tips/doc/trunk/tip/619.md
Tcl 8.6/8.7 always combines surrogates when it encounters a pair. This is wrong, since it makes the "string length" inconsistant: Glueing two strings together with length 1 (an Upper and a Lower surrogate) results in a new string with length 1. Because Tcl 8.7 uses 3 different internal representations (UTF-8, UTF-16 and UTF-32), and can freely switch between them, there's no way to distinguish a surrogate-pair and a code-point > U+FFFF.
In Tcl 9.0, Surrogates are never joined, so a round-trip between utf-8 -> utf-32 ->utf-8 is losless. That's the intention of TIP #619.
See also https://core.tcl-lang.org/tcl/tktview?name=0d61d3a2bb, which contains the discussion which lead to exactly this change.
Ok, thanks. I'll adapt the test cases accordingly.