diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-12-11 08:55:48 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-12-11 08:55:48 (GMT) |
commit | 81d54e6432bebe955c9fe5ef6bd4445e3e246d53 (patch) | |
tree | f87035745ca92837e78f1ec69a03abac79ed944a /generic/tclEncoding.c | |
parent | 112110625756d20f1587d8486e1a5196fccd3871 (diff) | |
parent | 1d6a94f9f809cab704789272afceeefb15e4b0db (diff) | |
download | tcl-81d54e6432bebe955c9fe5ef6bd4445e3e246d53.zip tcl-81d54e6432bebe955c9fe5ef6bd4445e3e246d53.tar.gz tcl-81d54e6432bebe955c9fe5ef6bd4445e3e246d53.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 475ec7c..375e519 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -2409,18 +2409,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); } |