diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-06-28 22:31:17 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-06-28 22:31:17 (GMT) |
commit | eb855ceb7719a330eb88618e2858135f4838dd23 (patch) | |
tree | 74d3b181d496eb04d88de36781123c6aede60306 | |
parent | 805e7986218616c662f180c3e0ae30844d0ad5c7 (diff) | |
parent | 5f5dec875b76abf0a55e531de9d358ba5b34485f (diff) | |
download | tk-eb855ceb7719a330eb88618e2858135f4838dd23.zip tk-eb855ceb7719a330eb88618e2858135f4838dd23.tar.gz tk-eb855ceb7719a330eb88618e2858135f4838dd23.tar.bz2 |
If encoding "utf-16" exists, use it in preference to "unicode", which is deprecated since TIP #547.
-rw-r--r-- | unix/tkUnixFont.c | 31 | ||||
-rw-r--r-- | win/tkWinX.c | 5 |
2 files changed, 13 insertions, 23 deletions
diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c index 96635b4..d00ff82 100644 --- a/unix/tkUnixFont.c +++ b/unix/tkUnixFont.c @@ -186,14 +186,7 @@ static EncodingAlias encodingAliases[] = { {"tis620", "tis620*"}, {"ksc5601", "ksc5601*"}, {"dingbats", "*dingbats"}, -#ifdef WORDS_BIGENDIAN - {"unicode", "iso10646-1"}, -#else - /* - * ucs-2be is needed if native order isn't BE. - */ {"ucs-2be", "iso10646-1"}, -#endif {NULL, NULL} }; @@ -246,7 +239,6 @@ static unsigned RankAttributes(FontAttributes *wantPtr, static void ReleaseFont(UnixFont *fontPtr); static void ReleaseSubFont(Display *display, SubFont *subFontPtr); static int SeenName(const char *name, Tcl_DString *dsPtr); -#ifndef WORDS_BIGENDIAN static int Ucs2beToUtfProc(ClientData clientData, const char*src, int srcLen, int flags, Tcl_EncodingState*statePtr, char *dst, int dstLen, int *srcReadPtr, @@ -255,7 +247,6 @@ static int UtfToUcs2beProc(ClientData clientData, const char*src, int srcLen, int flags, Tcl_EncodingState*statePtr, char *dst, int dstLen, int *srcReadPtr, int *dstWrotePtr, int *dstCharsPtr); -#endif /* *------------------------------------------------------------------------- @@ -320,9 +311,9 @@ TkpFontPkgInit( { ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - Tcl_EncodingType type; SubFont dummy; int i; + Tcl_Encoding ucs2; if (tsdPtr->controlFamily.encoding == NULL) { type.encodingName = "X11ControlChars"; @@ -343,20 +334,18 @@ TkpFontPkgInit( FontMapInsert(&dummy, i + 0x80); } -#ifndef WORDS_BIGENDIAN /* * UCS-2BE is unicode (UCS-2) in big-endian format. Define this if - * native order isn't BE. It is used in iso10646 fonts. + * if it doesn't exist yet. It is used in iso10646 fonts. */ - type.encodingName = "ucs-2be"; - type.toUtfProc = Ucs2beToUtfProc; - type.fromUtfProc = UtfToUcs2beProc; - type.freeProc = NULL; - type.clientData = NULL; - type.nullSize = 2; - Tcl_CreateEncoding(&type); -#endif + ucs2 = Tcl_GetEncoding(NULL, "ucs-2be"); + if (ucs2 == NULL) { + Tcl_EncodingType type = {"ucs-2be", Ucs2beToUtfProc, UtfToUcs2beProc, NULL, NULL, 2}; + Tcl_CreateEncoding(&type); + } else { + Tcl_FreeEncoding(ucs2); + } Tcl_CreateThreadExitHandler(FontPkgCleanup, NULL); } } @@ -459,7 +448,6 @@ ControlUtfProc( return result; } -#ifndef WORDS_BIGENDIAN /* *------------------------------------------------------------------------- * @@ -632,7 +620,6 @@ UtfToUcs2beProc( *dstCharsPtr = numChars; return result; } -#endif /* WORDS_BIGENDIAN */ /* *--------------------------------------------------------------------------- diff --git a/win/tkWinX.c b/win/tkWinX.c index 75064b5..e7428e5 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -1594,7 +1594,10 @@ Tcl_Encoding TkWinGetUnicodeEncoding(void) { if (unicodeEncoding == NULL) { - unicodeEncoding = Tcl_GetEncoding(NULL, "unicode"); + unicodeEncoding = Tcl_GetEncoding(NULL, "utf-16"); + if (unicodeEncoding == NULL) { + unicodeEncoding = Tcl_GetEncoding(NULL, "unicode"); + } } return unicodeEncoding; } |