Default action
The default action for data entering a Tcl interpreter through an input channel is to convert it from the external encoding to UTF-8. Data leaving the Tcl interpreter through an output channel undergoes the reverse conversion, that is, it is converted back to the external encoding). This default behavior is changed through Tcl command options. Channel input/output can be configured to perform no encoding conversions or to perform specific conversions.
The system Tcl extensions, and Tcl Xlate fragments, move data into and from Tcl interpreters as arrays of bytes instead of Tcl strings. No encoding conversions are performed when data is moved into an interpreter. Within the interpreter, Tcl commands requiring String data can convert the array of bytes to a UTF-8 string using ISO8859-1 encoding.
When a system Tcl extension moves data from an interpreter, the data is extracted as an array of bytes. If there is not a currently valid byte array representation of the data, then it is regenerated from the String representation. It does this by doing the UTF-8 to 16-bit Unicode encoding conversion and truncating the high-order byte.
Perform explicit external encoding to UTF-8 and reverse conversions to avoid data corruption and to perform correct transformations on the Unicode values in the data.