diff options
author | dgp <dgp@users.sourceforge.net> | 2011-06-10 20:14:39 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2011-06-10 20:14:39 (GMT) |
commit | 4348b1d1a803b524fd852a46fddaf6572f546827 (patch) | |
tree | aeffdde9ead5b6c4becdeee9212a8c316ebd3273 /generic/tkConsole.c | |
parent | 1047d6425a9d9c79430c35804acaeee884488f1e (diff) | |
parent | 4786156306bcb3c0800108b508b32ad99332fd54 (diff) | |
download | tk-4348b1d1a803b524fd852a46fddaf6572f546827.zip tk-4348b1d1a803b524fd852a46fddaf6572f546827.tar.gz tk-4348b1d1a803b524fd852a46fddaf6572f546827.tar.bz2 |
Merge to RC branch
Diffstat (limited to 'generic/tkConsole.c')
-rw-r--r-- | generic/tkConsole.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/generic/tkConsole.c b/generic/tkConsole.c index bdf6ccd..4091255 100644 --- a/generic/tkConsole.c +++ b/generic/tkConsole.c @@ -9,8 +9,6 @@ * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id: tkConsole.c,v 1.35.2.1 2009/10/15 17:48:50 dgp Exp $ */ #include "tk.h" @@ -509,7 +507,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 +530,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); |