Welcome to the CHICKEN Scheme pasting service

encoding-aware string added by gahr on Tue Oct 6 20:30:45 2026

$ cat encoding.tcl
chan configure stdin -encoding [lindex $::argv 0]
puts [string length [gets stdin]]


# valid utf-8 sequence, read from a binary stream, is 3 bytes (in Tcl, iso8859-1 means bytes are not interpreted, see https://www.tcl-lang.org/man/tcl9.1/TclCmd/chan.html#M11)

$ printf "\xe2\x82\xa1" | tclsh9.1 encoding.tcl iso8859-1
3

# valid utf-8 sequence, read from an utf-8 stream, is 1 character - the actual Unicode code point

$ printf "\xe2\x82\xa1" | tclsh9.1 encoding.tcl utf-8
1

# invalid utf-8 squence, read from a binary stream, is still 3 bytes

$ printf "\xe2\x28\xa1" | tclsh9.1 encoding.tcl iso8859-1
3

# invalid utf-8 sequence, read from an utf-8 stream, throws an error (in the default profile, for more info about profiles, see https://www.tcl-lang.org/man/tcl9.1/TclCmd/encoding.html#M15)

$ printf "\xe2\x28\xa1" | tclsh9.1 encoding.tcl utf-8
error reading "stdin": invalid or incomplete multibyte or wide character
    while executing
"gets stdin"
    invoked from within
"string length [gets stdin]"
    invoked from within
"puts [string length [gets stdin]]"
    (file "encoding.tcl" line 2)

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
What's the operator to construct procedures?