Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2023-04-08
11:27 • Ticket [dc23c64193] read fails, on encoding error, but current position advanc... artifact: d4f8cc9302 user: pooryorick
11:27 • Ticket [dc23c64193]: 3 changes artifact: b0605234b2 user: pooryorick
11:26 • New ticket [dc23c64193]. artifact: b5517f5a57 user: pooryorick

[read] fails, on encoding error, but current position advances anyway.

Opendc23c6419310c5f4d1d08c8681773e482e7a43b1Created 4 years agoUpdated 4 years ago
Descriptionwiki2023-04-08 11:26:50
Given the following script,
set chan [file tempfile]
chan configure $chan -translation binary -profile strict
puts -nonewline $chan hello\xc0world
chan configure $chan -encoding utf-8 -profile strict
seek $chan 0
catch {read $chan} errmsg
chan tell $chan ;# -> 5

, there is an invalid utf-8 sequence starting at position 5. read produces an error and chan tell report that the current position in the file has advanced to byte 5. Because the position has advanced, if the channel is not seekable, there is no way to adjust the channel configuration and try again.

On such a failure, either the position in the file should remain what it was before the unsuccessful read, or the result up to byte 5 should be made available to the caller.

pooryorick Ticket [dc23c64193]: 3 changes [History diff]2023-04-08 11:27:02
pooryorick Ticket [dc23c64193]: 3 changes [History diff]2023-04-08 11:27:22
Log in (anonymous is fine) to add a comment.