Skip to content
Tcl Source Code View Ticket
Login

View Ticket

[read] error persists on channel with strict encoding after encoding is changed to binary

Closed / Fixedeabcbd08274f2d22351fa96d972e4abfd08a8329Created 4 years agoUpdated 4 years ago
Descriptionwiki2023-04-16 23:02:06
In the script below, after the first [read] returns an encoding error, the channel is reconfigured to -encoding iso8859-1, and the subsequent [read] should return character \x81, but instead it repeats the error:
set res {}
set chan [file tempfile]
fconfigure $chan -encoding binary
# \x81 is invalid in utf-8. -eofchar is not detected, because it comes later.
puts -nonewline $chan A\x81\x1A
flush $chan
seek $chan 0
fconfigure $chan -encoding utf-8 -buffering none -eofchar \x1A \
-translation lf -profile strict
catch {read $chan} cres
puts $cres ;#-> error reading "file*": invalid or incomplete multibyte or wide character
puts [list eof [eof $chan]] ;#-> eof 1
puts [list position [tell $chan]] ;#-> position 1
chan configure $chan -encoding iso8859-1
catch {read $chan} cres
puts $cres] ;#-> error reading "file*": invalid or incomplete multibyte or wide character
pooryorickwiki2023-04-16 23:11:36

Fixed in [3fa3d48874].

pooryorick Ticket [eabcbd0827]: 3 changes [History diff]2023-04-16 23:20:09
pooryorick Ticket [eabcbd0827]: 4 changes [History diff]2023-04-19 07:14:01
pooryorick Closed ticket [eabcbd0827]. [History diff]2023-04-21 23:02:25
Log in (anonymous is fine) to add a comment.