Tcl Source Code

View Ticket
Login
Ticket UUID: eabcbd08274f2d22351fa96d972e4abfd08a8329
Title: [read] error persists on channel with strict encoding after encoding is changed to binary
Type: Bug Version:
Submitter: pooryorick Created on: 2023-04-16 23:02:06
Subsystem: - New Builtin Commands Assigned To: pooryorick
Priority: 5 Medium Severity: Important
Status: Closed Last Modified: 2023-04-21 23:02:25
Resolution: Fixed Closed By: pooryorick
    Closed on: 2023-04-21 23:02:25
Description: (text/x-fossil-wiki)
In the script below, after the first [read] returns an encoding error, the
channel is reconfigured to <code>-encoding iso8859-1</code>, and the
subsequent [read] should return character <code>\x81</code>, but instead it
repeats the error:

<blockquote><code><verbatim>
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
</verbatim></code></blockquote>
User Comments: pooryorick added on 2023-04-16 23:11:36: (text/x-fossil-wiki)
Fixed in [3fa3d48874].