diff options
author | dgp <dgp@users.sourceforge.net> | 2011-06-06 21:57:28 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2011-06-06 21:57:28 (GMT) |
commit | 1561619c55815e32523818007685d998b7fc7ea8 (patch) | |
tree | 410338316d61546a6a5132f3e9a1b2362e014fc5 /generic | |
parent | 3432d17f8cf090f38741cd3d00536bd318cee1fe (diff) | |
parent | 255c998c4d6b7a3a342bbb8d3184f0f4365d33f5 (diff) | |
download | tk-1561619c55815e32523818007685d998b7fc7ea8.zip tk-1561619c55815e32523818007685d998b7fc7ea8.tar.gz tk-1561619c55815e32523818007685d998b7fc7ea8.tar.bz2 |
Restore proper NUL output to the [console]. [Bug 2546087]
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tkConsole.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/generic/tkConsole.c b/generic/tkConsole.c index bdf6ccd..f996361 100644 --- a/generic/tkConsole.c +++ b/generic/tkConsole.c @@ -509,7 +509,22 @@ ConsoleOutput( Tcl_Interp *consoleInterp = info->consoleInterp; if (consoleInterp && !Tcl_InterpDeleted(consoleInterp)) { + Tcl_DString ds; + Tcl_Encoding utf8 = Tcl_GetEncoding(NULL, "utf-8"); + + /* + * Not checking for utf8 == NULL. Did not check for TCL_ERROR + * from Tcl_SetChannelOption() in Tk_InitConsoleChannels() either. + * Assumption is utf-8 Tcl_Encoding is reliably present. + */ + + CONST char *bytes + = Tcl_ExternalToUtfDString(utf8, buf, toWrite, &ds); + int numBytes = Tcl_DStringLength(&ds); Tcl_Obj *cmd = Tcl_NewStringObj("tk::ConsoleOutput", -1); + + Tcl_FreeEncoding(utf8); + if (data->type == TCL_STDERR) { Tcl_ListObjAppendElement(NULL, cmd, Tcl_NewStringObj("stderr", -1)); @@ -517,7 +532,10 @@ ConsoleOutput( Tcl_ListObjAppendElement(NULL, cmd, Tcl_NewStringObj("stdout", -1)); } - Tcl_ListObjAppendElement(NULL, cmd, Tcl_NewStringObj(buf, toWrite)); + Tcl_ListObjAppendElement(NULL, cmd, + Tcl_NewStringObj(bytes, numBytes)); + + Tcl_DStringFree(&ds); Tcl_IncrRefCount(cmd); Tcl_GlobalEvalObj(consoleInterp, cmd); Tcl_DecrRefCount(cmd); |