summaryrefslogtreecommitdiffstats
path: root/generic/tclEncoding.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-12-11 15:53:07 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-12-11 15:53:07 (GMT)
commit74f50a92f3da3af11e792ce50837624434587b54 (patch)
tree83776d7b45e1006d3558f3895173c1075bf266e0 /generic/tclEncoding.c
parent743e03cf5e6eb1b9679f21e613513de51f874878 (diff)
parent1d6a94f9f809cab704789272afceeefb15e4b0db (diff)
downloadtcl-74f50a92f3da3af11e792ce50837624434587b54.zip
tcl-74f50a92f3da3af11e792ce50837624434587b54.tar.gz
tcl-74f50a92f3da3af11e792ce50837624434587b54.tar.bz2
Merge 8.7
Diffstat (limited to 'generic/tclEncoding.c')
-rw-r--r--generic/tclEncoding.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c
index 1bed847..0f5337e 100644
--- a/generic/tclEncoding.c
+++ b/generic/tclEncoding.c
@@ -2414,18 +2414,19 @@ UtfToUtfProc(
dst += Tcl_UniCharToUtf(*chPtr, dst);
} else {
src += TclUtfToUniChar(src, chPtr);
- if ((*chPtr | 0x3FF) == 0xDBFF) {
- /* A high surrogate character is detected, handle especially */
+ if ((*chPtr | 0x7FF) == 0xDFFF) {
+ /* A surrogate character is detected, handle especially */
Tcl_UniChar low = *chPtr;
- if (src <= srcEnd-3) {
- Tcl_UtfToUniChar(src, &low);
- }
- if ((low | 0x3FF) != 0xDFFF) {
+ size_t len = (src <= srcEnd-3) ? Tcl_UtfToUniChar(src, &low) : 0;
+ if (((low | 0x3FF) != 0xDFFF) || (*chPtr & 0x400)) {
*dst++ = (char) (((*chPtr >> 12) | 0xE0) & 0xEF);
*dst++ = (char) (((*chPtr >> 6) | 0x80) & 0xBF);
*dst++ = (char) ((*chPtr | 0x80) & 0xBF);
continue;
}
+ src += len;
+ dst += Tcl_UniCharToUtf(*chPtr, dst);
+ *chPtr = low;
}
dst += Tcl_UniCharToUtf(*chPtr, dst);
}