diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2022-03-23 14:32:08 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2022-03-23 14:32:08 (GMT) |
commit | 369bc9b1594ea304387a97eef5658a5998699534 (patch) | |
tree | b2c7ce0bf6448ce8deeb65e8bd81611155c53831 | |
parent | 1f3d3d7671748e4eb36cc0846e3e953bdb29c227 (diff) | |
download | tcl-369bc9b1594ea304387a97eef5658a5998699534.zip tcl-369bc9b1594ea304387a97eef5658a5998699534.tar.gz tcl-369bc9b1594ea304387a97eef5658a5998699534.tar.bz2 |
Fix Tcl_UniCharAtIndex() for UTF-16 compabitility layer
-rw-r--r-- | generic/tclUtf.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/generic/tclUtf.c b/generic/tclUtf.c index eda317f..cfd9915 100644 --- a/generic/tclUtf.c +++ b/generic/tclUtf.c @@ -1182,22 +1182,20 @@ Tcl_UniCharAtIndex( const char *src, /* The UTF-8 string to dereference. */ int index) /* The position of the desired character. */ { - Tcl_UniChar ch = 0; + unsigned short ch = 0; int i = 0; if (index < 0) { return -1; } while (index-- > 0) { - i = TclUtfToUniChar(src, &ch); + i = Tcl_UtfToChar16(src, &ch); src += i; } -#if TCL_UTF_MAX < 4 if ((ch >= 0xD800) && (i < 3)) { /* Index points at character following high Surrogate */ return -1; } -#endif TclUtfToUCS4(src, &i); return i; } |