summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
Diffstat (limited to 'generic')
-rw-r--r--generic/tclUtf.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/generic/tclUtf.c b/generic/tclUtf.c
index 0d88d36..c08464b 100644
--- a/generic/tclUtf.c
+++ b/generic/tclUtf.c
@@ -762,10 +762,18 @@ Tcl_UtfAtIndex(
register int index) /* The position of the desired character. */
{
Tcl_UniChar ch = 0;
+ int len = 1;
while (index-- > 0) {
+ len = TclUtfToUniChar(src, &ch);
+ src += len;
+ }
+#if TCL_UTF_MAX == 4
+ if (!len) {
+ /* Index points at character following High Surrogate */
src += TclUtfToUniChar(src, &ch);
}
+#endif
return src;
}