Skip to content
Tcl Source Code View Ticket
Login

View Ticket

convertfrom utf-8 strict mode allows surrogates in input sequence

Closed / Fixedbd1a60eb9c080fc419473d7fadc6048d5753daa8Created 4 years agoUpdated 4 years ago
Descriptionmarkdown2023-02-11 16:23:52

I think the following is a bug as conformant utf-8 streams are explicitly not permitted to have encoded surrogates.

% proc codepoints {s} {join [lmap c [split $s ""] {
    string cat U+ [format %.6X [scan $c %c]]}]
}
% codepoints [encoding convertfrom -strict utf-8 \xed\xa0\x80\xed\xb0\x80]
U+010000

Above should generate an exception.

Looking at fixing (in apn-encoding-profile branch for now, but above sample is from core-8-branch).

Tcl9 behaves as expected.

% codepoints [encoding convertfrom -strict utf-8 \xed\xa0\x80\xed\xb0\x80]
unexpected byte sequence starting at index 0: '\xED'
Referenced by6
apnadkarni Ticket [bd1a60eb9c]: 3 changes [History diff]2023-02-11 16:32:24
jan.nijtmans Ticket [bd1a60eb9c]: 3 changes [History diff]2023-02-13 22:12:17
jan.nijtmanswiki2023-02-15 07:32:15

Fixed now in core-8-branch and trunk

pooryorickwiki2023-04-16 13:21:48

Jan's fix is in [84f30c5d4ee1a14a].

Log in (anonymous is fine) to add a comment.