diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-12-11 15:53:07 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-12-11 15:53:07 (GMT) |
commit | 74f50a92f3da3af11e792ce50837624434587b54 (patch) | |
tree | 83776d7b45e1006d3558f3895173c1075bf266e0 /generic/tclEncoding.c | |
parent | 743e03cf5e6eb1b9679f21e613513de51f874878 (diff) | |
parent | 1d6a94f9f809cab704789272afceeefb15e4b0db (diff) | |
download | tcl-74f50a92f3da3af11e792ce50837624434587b54.zip tcl-74f50a92f3da3af11e792ce50837624434587b54.tar.gz tcl-74f50a92f3da3af11e792ce50837624434587b54.tar.bz2 |
Merge 8.7
Diffstat (limited to 'generic/tclEncoding.c')
-rw-r--r-- | generic/tclEncoding.c | 13 |
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); } |