diff options
author | dgp <dgp@users.sourceforge.net> | 2011-06-06 22:06:07 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2011-06-06 22:06:07 (GMT) |
commit | 1a3bb9c68a97c79e52cff4a3ecf1fed6065985d1 (patch) | |
tree | e97a209a0de1adc679dbf9d5c4c146263ac0a0e9 /generic/tkConsole.c | |
parent | c2704bf225e6776ce585a4a96c9e4253c82e8e77 (diff) | |
parent | 2da308287ac0cb828ac2fd46fa33981a0a80c547 (diff) | |
download | tk-1a3bb9c68a97c79e52cff4a3ecf1fed6065985d1.zip tk-1a3bb9c68a97c79e52cff4a3ecf1fed6065985d1.tar.gz tk-1a3bb9c68a97c79e52cff4a3ecf1fed6065985d1.tar.bz2 |
Restore proper NUL output to the [console]. [Bug 2546087]
Diffstat (limited to 'generic/tkConsole.c')
-rw-r--r-- | generic/tkConsole.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/generic/tkConsole.c b/generic/tkConsole.c index cb16ca2..0335e76 100644 --- a/generic/tkConsole.c +++ b/generic/tkConsole.c @@ -513,8 +513,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)); @@ -523,7 +537,9 @@ ConsoleOutput( Tcl_NewStringObj("stdout", -1)); } Tcl_ListObjAppendElement(NULL, cmd, - Tcl_NewStringObj(buf, toWrite)); + Tcl_NewStringObj(bytes, numBytes)); + + Tcl_DStringFree(&ds); Tcl_IncrRefCount(cmd); Tcl_GlobalEvalObj(consoleInterp, cmd); Tcl_DecrRefCount(cmd); |