diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-03-15 20:24:47 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-03-15 20:24:47 (GMT) |
commit | 5d3696a737a0d6cbfc1c3eda16547cff2f9078d7 (patch) | |
tree | ad635935285c9cb8e34d1f1c7cb147700351236e /generic/tkMain.c | |
parent | e7ffce5e2c326fd4b70d785a4cab86708aa9c9df (diff) | |
download | tk-5d3696a737a0d6cbfc1c3eda16547cff2f9078d7.zip tk-5d3696a737a0d6cbfc1c3eda16547cff2f9078d7.tar.gz tk-5d3696a737a0d6cbfc1c3eda16547cff2f9078d7.tar.bz2 |
Make Tk run on win32/win64 using -DTCL_UTF_MAX=6. Adapted from androwish.
Diffstat (limited to 'generic/tkMain.c')
-rw-r--r-- | generic/tkMain.c | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/generic/tkMain.c b/generic/tkMain.c index a7d4ca1..3600142 100644 --- a/generic/tkMain.c +++ b/generic/tkMain.c @@ -79,22 +79,35 @@ extern const TclIntPlatStubs *tclIntPlatStubsPtr; #endif /* - * Further on, in UNICODE mode, we need to use Tcl_NewUnicodeObj, - * while otherwise NewNativeObj is needed (which provides proper - * conversion from native encoding to UTF-8). + * Further on, in UNICODE mode we just use Tcl_NewUnicodeObj, otherwise + * NewNativeObj is needed (which provides proper conversion from native + * encoding to UTF-8). */ -#ifdef UNICODE + +#if defined(UNICODE) && (TCL_UTF_MAX <= 4) # define NewNativeObj Tcl_NewUnicodeObj -#else /* !UNICODE */ - static Tcl_Obj *NewNativeObj(char *string, int length) { - Tcl_Obj *obj; - Tcl_DString ds; - Tcl_ExternalToUtfDString(NULL, string, length, &ds); - obj = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds)); - Tcl_DStringFree(&ds); - return obj; +#else /* !UNICODE || (TCL_UTF_MAX > 4) */ +static inline Tcl_Obj * +NewNativeObj( + TCHAR *string, + int length) +{ + Tcl_Obj *obj; + Tcl_DString ds; + +#ifdef UNICODE + if (length > 0) { + length *= sizeof(WCHAR); + } + Tcl_WinTCharToUtf(string, length, &ds); +#else + Tcl_ExternalToUtfDString(NULL, (char *) string, length, &ds); +#endif + obj = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds)); + Tcl_DStringFree(&ds); + return obj; } -#endif /* !UNICODE */ +#endif /* !UNICODE || (TCL_UTF_MAX > 4) */ /* * Declarations for various library functions and variables (don't want to |