diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-11-27 16:16:12 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-11-27 16:16:12 (GMT) |
commit | 2b3b6f6334373b0e5eec61731bf83e629235d3ed (patch) | |
tree | 0b0fa52462e7ee64c7abec743613858d291882e1 /generic/tkUtil.c | |
parent | c178a6ce365f3826b96df6ad722a875b958cdcc9 (diff) | |
download | tk-2b3b6f6334373b0e5eec61731bf83e629235d3ed.zip tk-2b3b6f6334373b0e5eec61731bf83e629235d3ed.tar.gz tk-2b3b6f6334373b0e5eec61731bf83e629235d3ed.tar.bz2 |
Starting work to compile Tk with TCL_UTF_MAX=4 (WIP)
Diffstat (limited to 'generic/tkUtil.c')
-rw-r--r-- | generic/tkUtil.c | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/generic/tkUtil.c b/generic/tkUtil.c index d3bf058..b4ce9fe 100644 --- a/generic/tkUtil.c +++ b/generic/tkUtil.c @@ -1246,79 +1246,6 @@ Tk_SendVirtualEvent( Tk_QueueWindowEvent(&event.general, TCL_QUEUE_TAIL); } -#if TCL_UTF_MAX < 4 -/* - *--------------------------------------------------------------------------- - * - * TkUtfToUniChar -- - * - * Almost the same as Tcl_UtfToUniChar but using int instead of Tcl_UniChar. - * This function is capable of collapsing a upper/lower surrogate pair to a - * single unicode character. So, up to 6 bytes might be consumed. - * - * Results: - * *chPtr is filled with the Tcl_UniChar, and the return value is the - * number of bytes from the UTF-8 string that were consumed. - * - * Side effects: - * None. - * - *--------------------------------------------------------------------------- - */ - -size_t -TkUtfToUniChar( - const char *src, /* The UTF-8 string. */ - int *chPtr) /* Filled with the Unicode value represented by - * the UTF-8 string. */ -{ - Tcl_UniChar uniChar = 0; - - size_t len = Tcl_UtfToUniChar(src, &uniChar); - if ((uniChar & 0xFC00) == 0xD800) { - Tcl_UniChar low = uniChar; - /* This can only happen if sizeof(Tcl_UniChar)== 2 and src points - * to a character > U+FFFF */ - size_t len2 = Tcl_UtfToUniChar(src+len, &low); - if ((low & 0xFC00) == 0xDC00) { - *chPtr = (((uniChar & 0x3FF) << 10) | (low & 0x3FF)) + 0x10000; - return len + len2; - } - } - *chPtr = uniChar; - return len; -} - -/* - *--------------------------------------------------------------------------- - * - * TkUniCharToUtf -- - * - * Almost the same as Tcl_UniCharToUtf but producing 2 x 3-byte UTF-8 - * sequences for out-of-bmp characters when TCL_UTF_MAX==3. - * So, up to 6 bytes might be produced. - * - * Results: - * *buf is filled with the UTF-8 string, and the return value is the - * number of bytes produced. - * - * Side effects: - * None. - * - *--------------------------------------------------------------------------- - */ - -size_t TkUniCharToUtf(int ch, char *buf) -{ - if ((unsigned)(ch - 0x10000) <= 0xFFFFF) { - /* Spit out a 4-byte UTF-8 character or 2 x 3-byte UTF-8 characters, depending on Tcl - * version and/or TCL_UTF_MAX build value */ - int len = Tcl_UniCharToUtf(0xD800 | ((ch - 0x10000) >> 10), buf); - return len + Tcl_UniCharToUtf(0xDC00 | (ch & 0x7FF), buf + len); - } - return Tcl_UniCharToUtf(ch, buf); -} -#endif /* * Local Variables: * mode: c |