Index: kitsh/buildsrc/kitsh-0.0/boot.tcl ================================================================== --- kitsh/buildsrc/kitsh-0.0/boot.tcl +++ kitsh/buildsrc/kitsh-0.0/boot.tcl @@ -87,15 +87,21 @@ encoding dirs [list [file join [info library] encoding]] ;# TIP 258 } # fix system encoding, if it wasn't properly set up (200207.004 bug) if {[encoding system] eq "identity"} { - switch $::tcl_platform(platform) { - windows { encoding system cp1252 } - macintosh { encoding system macRoman } - default { encoding system iso8859-1 } + if {[info exists ::tclkit_system_encoding] && $::tclkit_system_encoding != ""} { + encoding system $::tclkit_system_encoding + } else { + switch $::tcl_platform(platform) { + windows { encoding system cp1252 } + macintosh { encoding system macRoman } + default { encoding system iso8859-1 } + } } + + unset -nocomplain ::tclkit_system_encoding } # now remount the executable with the correct encoding vfs::filesystem unmount [lindex [::vfs::filesystem info] 0] Index: kitsh/buildsrc/kitsh-0.0/configure.ac ================================================================== --- kitsh/buildsrc/kitsh-0.0/configure.ac +++ kitsh/buildsrc/kitsh-0.0/configure.ac @@ -30,14 +30,17 @@ dnl If we found the resource compiler, add "kit.res.o" to our list of objects to build if ! test "$RC" = "false"; then EXTRA_OBJS="$EXTRA_OBJS kit.res.o" fi -dnl Determine if we have "Tcl_SetStartupScript" (8.6.x) or "TclSetStartupScriptPath" (8.4.x) +dnl Check for Tcl features SAVE_LIBS="${LIBS}" LIBS="${ARCHS} ${LIBS}" +dnl Determine if we have "Tcl_SetStartupScript" (8.6.x) or "TclSetStartupScriptPath" (8.4.x) AC_CHECK_FUNCS(Tcl_SetStartupScript TclSetStartupScriptPath) +dnl Check for the ability to get the current system encoding +AC_CHECK_FUNCS(Tcl_GetEncodingNameFromEnvironment Tcl_SetSystemEncoding) LIBS="${SAVE_LIBS}" dnl Find zlib AC_ARG_WITH(zlib, AC_HELP_STRING([--with-zlib], [directory containing zlib]), [ CPPFLAGS="${CPPFLAGS} -I${with_zlib}/include -I${with_zlib}" Index: kitsh/buildsrc/kitsh-0.0/kitInit.c ================================================================== --- kitsh/buildsrc/kitsh-0.0/kitInit.c +++ kitsh/buildsrc/kitsh-0.0/kitInit.c @@ -30,22 +30,32 @@ #ifndef MB_TASKMODAL # define MB_TASKMODAL 0 #endif /* MB_TASKMODAL */ #include "tclInt.h" + +#if defined(HAVE_TCL_GETENCODINGNAMEFROMENVIRONMENT) && defined(HAVE_TCL_SETSYSTEMENCODING) +# define TCLKIT_CAN_SET_ENCODING 1 +#endif +#if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION < 85 +# define KIT_INCLUDES_PWB 1 +#endif +#if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION < 86 +# define KIT_INCLUDES_ZLIB 1 +#endif #ifdef KIT_INCLUDES_ITCL Tcl_AppInitProc Itcl_Init; #endif #ifdef KIT_INCLUDES_MK4TCL Tcl_AppInitProc Mk4tcl_Init; #endif Tcl_AppInitProc Vfs_Init, Rechan_Init; -#if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION < 85 +#ifdef KIT_INCLUDES_PWB Tcl_AppInitProc Pwb_Init; #endif -#if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION < 86 +#ifdef KIT_INCLUDES_ZLIB Tcl_AppInitProc Zlib_Init; #endif #ifdef TCL_THREADS Tcl_AppInitProc Thread_Init; #endif @@ -162,22 +172,26 @@ tclExecutableName = strdup(Tcl_GetStringFromObj(execNameObj, &len)); } } int TclKit_AppInit(Tcl_Interp *interp) { +#ifdef TCLKIT_CAN_SET_ENCODING + Tcl_DString encodingName; +#endif + #ifdef KIT_INCLUDES_ITCL Tcl_StaticPackage(0, "Itcl", Itcl_Init, NULL); #endif #ifdef KIT_INCLUDES_MK4TCL Tcl_StaticPackage(0, "Mk4tcl", Mk4tcl_Init, NULL); #endif -#if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION < 85 +#ifdef KIT_INCLUDES_PWB Tcl_StaticPackage(0, "pwb", Pwb_Init, NULL); #endif Tcl_StaticPackage(0, "rechan", Rechan_Init, NULL); Tcl_StaticPackage(0, "vfs", Vfs_Init, NULL); -#if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION < 86 +#ifdef KIT_INCLUDES_ZLIB Tcl_StaticPackage(0, "zlib", Zlib_Init, NULL); #endif #ifdef TCL_THREADS Tcl_StaticPackage(0, "Thread", Thread_Init, NULL); #endif @@ -193,10 +207,18 @@ #ifdef _WIN32 Tcl_SetVar(interp, "tcl_rcFileName", "~/tclkitrc.tcl", TCL_GLOBAL_ONLY); #else Tcl_SetVar(interp, "tcl_rcFileName", "~/.tclkitrc", TCL_GLOBAL_ONLY); #endif + +#ifdef TCLKIT_CAN_SET_ENCODING + /* Set the encoding from the Environment */ + Tcl_GetEncodingNameFromEnvironment(&encodingName); + Tcl_SetSystemEncoding(NULL, Tcl_DStringValue(&encodingName)); + Tcl_SetVar(interp, "tclkit_system_encoding", Tcl_DStringValue(&encodingName), 0); + Tcl_DStringFree(&encodingName); +#endif /* Hack to get around Tcl bug 1224888. This must be run here and * in LibraryPathObjCmd because this information is needed both * before and after that command is run. */ SetExecName(interp);