| ︙ | | |
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
|
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
|
-
+
-
+
|
fconfigure $in -encoding ascii -profile strict
fconfigure $out -encoding koi8-r -translation lf
fcopy $in $out
} -cleanup {
close $in
close $out
} -returnCodes 1 -match glob -result {error reading "file*": illegal byte sequence}
} -returnCodes 1 -match glob -result {error reading "file*": invalid or incomplete multibyte or wide character}
test io-52.21 {TclCopyChannel & encodings} -setup {
set out [open $path(utf8-fcopy.txt) w]
fconfigure $out -encoding utf-8 -translation lf
puts $out "Á"
close $out
} -constraints {fcopy} -body {
# binary to encoding => the input has to be
# in utf-8 to make sense to the encoder
set in [open $path(utf8-fcopy.txt) r]
set out [open $path(kyrillic.txt) w]
# Using "-encoding ascii" means writing the "Á" gives an error
fconfigure $in -encoding utf-8
fconfigure $out -encoding ascii -translation lf -profile strict
fcopy $in $out
} -cleanup {
close $in
close $out
} -returnCodes 1 -match glob -result {error writing "file*": illegal byte sequence}
} -returnCodes 1 -match glob -result {error writing "file*": invalid or incomplete multibyte or wide character}
test io-52.22 {TclCopyChannel & encodings} -setup {
set out [open $path(utf8-fcopy.txt) w]
fconfigure $out -encoding utf-8 -translation lf
puts $out "Á"
close $out
} -constraints {fcopy} -body {
# binary to encoding => the input has to be
|
| ︙ | | |
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
|
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
|
-
+
|
fcopy $in $out -command ::xxx
vwait ::s0
set ::s0
} -cleanup {
close $in
close $out
unset ::s0
} -match glob -result {0 {error reading "file*": illegal byte sequence}}
} -match glob -result {0 {error reading "file*": invalid or incomplete multibyte or wide character}}
test io-52.23 {TclCopyChannel & encodings} -setup {
set out [open $path(utf8-fcopy.txt) w]
fconfigure $out -encoding utf-8 -translation lf
puts $out "Á"
close $out
} -constraints {fcopy} -body {
# binary to encoding => the input has to be
|
| ︙ | | |
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
|
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
|
-
+
|
fcopy $in $out -command ::xxx
vwait ::s0
set ::s0
} -cleanup {
close $in
close $out
unset ::s0
} -match glob -result {0 {error writing "file*": illegal byte sequence}}
} -match glob -result {0 {error writing "file*": invalid or incomplete multibyte or wide character}}
test io-53.1 {CopyData} {fcopy} {
file delete $path(test1)
set f1 [open $thisScript]
set f2 [open $path(test1) w]
fconfigure $f1 -translation lf -blocking 0
|
| ︙ | | |
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
|
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
|
-
+
|
variable x ""
set result ""
vwait [namespace which -variable x]
# cut of the remainder of the error stack, especially the filename
set result [lreplace $result 3 3 [lindex [split [lindex $result 3] \n] 0]]
list $x $result
} {1 {gets ABC catch {error writing "stdout": illegal byte sequence}}}
} {1 {gets ABC catch {error writing "stdout": invalid or incomplete multibyte or wide character}}}
test io-61.1 {Reset eof state after changing the eof char} -setup {
set datafile [makeFile {} eofchar]
set f [open $datafile w]
fconfigure $f -translation binary
puts -nonewline $f [string repeat "Ho hum\n" 11]
puts $f =
|
| ︙ | | |
9224
9225
9226
9227
9228
9229
9230
9231
9232
9233
9234
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253
9254
|
9224
9225
9226
9227
9228
9229
9230
9231
9232
9233
9234
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253
9254
|
-
+
-
+
|
seek $f 0
fconfigure $f -encoding utf-8 -buffering none -eofchar "" -translation lf -profile strict
} -body {
gets $f
} -cleanup {
close $f
removeFile io-75.6
} -match glob -returnCodes 1 -result {error reading "*": illegal byte sequence}
} -match glob -returnCodes 1 -result {error reading "*": invalid or incomplete multibyte or wide character}
test io-75.7 {invalid utf-8 encoding gets is not ignored (-profile strict)} -setup {
set fn [makeFile {} io-75.7]
set f [open $fn w+]
fconfigure $f -encoding binary
# \x81 is invalid in utf-8
puts -nonewline $f A\x81
flush $f
seek $f 0
fconfigure $f -encoding utf-8 -buffering none -eofchar "" -translation lf -profile strict
} -body {
read $f
} -cleanup {
close $f
removeFile io-75.7
} -match glob -returnCodes 1 -result {error reading "*": illegal byte sequence}
} -match glob -returnCodes 1 -result {error reading "*": invalid or incomplete multibyte or wide character}
test io-75.8 {invalid utf-8 encoding eof handling (-profile strict)} -setup {
set fn [makeFile {} io-75.8]
set f [open $fn w+]
fconfigure $f -encoding binary
# \x81 is invalid in utf-8, but since \x1A comes first, -eofchar takes precedence.
puts -nonewline $f A\x1A\x81
|
| ︙ | | |
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
|
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
|
-
+
|
catch {puts -nonewline $f "A\u2022"} msg
flush $f
seek $f 0
list [read $f] $msg
} -cleanup {
close $f
removeFile io-75.9
} -match glob -result [list {A} {error writing "*": illegal byte sequence}]
} -match glob -result [list {A} {error writing "*": invalid or incomplete multibyte or wide character}]
# Incomplete sequence test.
# This error may IMHO only be detected with the close.
# But the read already returns the incomplete sequence.
test io-75.10 {incomplete multibyte encoding read is ignored} -setup {
set fn [makeFile {} io-75.10]
set f [open $fn w+]
|
| ︙ | | |
9318
9319
9320
9321
9322
9323
9324
9325
9326
9327
9328
9329
9330
9331
9332
|
9318
9319
9320
9321
9322
9323
9324
9325
9326
9327
9328
9329
9330
9331
9332
|
-
+
|
set d [read $f]
binary scan $d H* hd
lappend hd [catch {set d [read $f]} msg]
lappend hd $msg
} -cleanup {
close $f
removeFile io-75.11
} -match glob -result {41 1 {error reading "*": illegal byte sequence}}
} -match glob -result {41 1 {error reading "*": invalid or incomplete multibyte or wide character}}
test io-75.12 {invalid utf-8 encoding read is ignored} -setup {
set fn [makeFile {} io-75.12]
set f [open $fn w+]
fconfigure $f -encoding binary
puts -nonewline $f A\x81
flush $f
|
| ︙ | | |
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363
9364
9365
9366
9367
|
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363
9364
9365
9366
9367
|
-
+
|
set d [read $f]
binary scan $d H* hd
lappend hd [catch {read $f} msg]
lappend hd $msg
} -cleanup {
close $f
removeFile io-75.13
} -match glob -result {41 1 {error reading "*": illegal byte sequence}}
} -match glob -result {41 1 {error reading "*": invalid or incomplete multibyte or wide character}}
# ### ### ### ######### ######### #########
test io-76.0 {channel modes} -setup {
set datafile [makeFile {some characters} dummy]
|
| ︙ | | |