diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2021-03-23 16:33:25 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2021-03-23 16:33:25 (GMT) |
commit | 811f1574bb3980d57f05b8334bd6d1aecdf4e32e (patch) | |
tree | 5c50bc92e0098cc8488749e26c997f058689794a /generic/tkTextIndex.c | |
parent | cb689d388a07704cc34424caf91ff48bf6a3953b (diff) | |
download | tk-811f1574bb3980d57f05b8334bd6d1aecdf4e32e.zip tk-811f1574bb3980d57f05b8334bd6d1aecdf4e32e.tar.gz tk-811f1574bb3980d57f05b8334bd6d1aecdf4e32e.tar.bz2 |
Fix 3 places where Tcl_UtfToUniChar must be used and not TkUtfToUniChar: numChars/charIndex is counting character indexes here; surrogate-pairs count as 2.
This can cause a miscount when Emoji are pasted in a Text widget.
Diffstat (limited to 'generic/tkTextIndex.c')
-rw-r--r-- | generic/tkTextIndex.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/generic/tkTextIndex.c b/generic/tkTextIndex.c index 1628389..84bdbee 100644 --- a/generic/tkTextIndex.c +++ b/generic/tkTextIndex.c @@ -480,7 +480,7 @@ TkTextMakeCharIndex( TkTextSegment *segPtr; char *p, *start, *end; int index, offset; - int ch; + Tcl_UniChar ch = 0; indexPtr->tree = tree; if (lineIndex < 0) { @@ -527,7 +527,7 @@ TkTextMakeCharIndex( return indexPtr; } charIndex--; - offset = TkUtfToUniChar(p, &ch); + offset = Tcl_UtfToUniChar(p, &ch); index += offset; } } else { |