Posted to tcl by de at Mon Dec 19 08:43:46 GMT 2022view pretty
# Create the data; works with Tcl 8 and 9 set fd [open "data.txt" w+] fconfigure $fd -encoding binary puts -nonewline $fd \xc0\x40 close $fd # Read this with Tcl 9 / current trunk package require Tcl 9 set fd [open "data.txt"] fconfigure $fd -encoding utf-8 set data [read $fd] close $fd puts $data package require Tcl 9 set fd [open "data.txt"] fconfigure $fd -encoding utf-8 -strictencoding 1 set data [read $fd] close $fd puts $data # Create the data package require Tcl 9 set fd [open "data.txt" w+] fconfigure $fd -encoding utf-8 puts -nonewline $fd A\U10FFFFB close $fd # Read it back set fd [open "data.txt"] fconfigure $fd -encoding utf-8 -strictencoding 1 set data [read $fd] close $fd puts $data