Please see the following session:
godel:81> expect
expect1.1> info patch
8.3.4
expect1.2> set a "x\00y"
xŔy
expect1.3> puts $a
xy
expect1.4> fconfigure stdout
-blocking 1 -buffering line -buffersize 4096 -encoding iso8859-1
-eofchar {} -translation lf
expect1.5>
The null character is printed as Ŕ from expect's interactive shell on a
solaris2.6 machine. This does not happen if I run the same commands in a
tclsh interactive shell. So, I think there's a bug in printing function
that is called by the expect's interactive shell.
Logged In: YES
user_id=75003
Investigative data:
* Tcl: File "tclMain.c", line 403ff.
Result is retrieved as object,
retrieved as UTF/8-string, written
to standard channel using an API
which does conversion of the string
to external encoding.
* Expect: exp_main_sub.c, line376ff
(Function 'exp_interpreter'), retrieve
raw bytes of result, not as string.
Other functions: exp_cook /ok
expStdoutLogU,
expDiagWriteBytes
LOGUSER => Direct fwrite to stdout,
no conversion
logchannel => Tcl_WriteChars converts.
diagChannel => Tcl_Write, no conversion.
This code-path (exp_interpreter) is also
used by the tcl-level commands [exp_interact]
and [exp_interpreter].
Proposed change: Retrieve result as string,
convert explicitly to external encoding and
use that as argument to the log function.
Logged In: YES
user_id=75003
Tentative fix in uploaded patch.
Compiles, passes testsuite.
Expect shell behaves like Tcl
shell with this patch.
Possible fix, unified diff
Logged In: YES
user_id=75003
Committed to "expect-sf418892-sf439042-branch".
Logged In: YES
user_id=75003
Merged into head.