diff options
| -rw-r--r-- | generic/tclEncoding.c | 15 | ||||
| -rw-r--r-- | generic/tclTomMath.decls | 4 | ||||
| -rw-r--r-- | tests/encoding.test | 24 |
3 files changed, 27 insertions, 16 deletions
diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index 351d7ac..afba9aa 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -2304,7 +2304,7 @@ UtfToUtfProc( } dstStart = dst; - dstEnd = dst + dstLen - ((pureNullMode == 1) ? 4 : TCL_UTF_MAX); + dstEnd = dst + dstLen - TCL_UTF_MAX; for (numChars = 0; src < srcEnd && numChars <= charLimit; numChars++) { if ((src > srcClose) && (!Tcl_UtfCharComplete(src, srcEnd - src))) { @@ -2350,21 +2350,14 @@ UtfToUtfProc( if ((*chPtr & 0xFC00) == 0xD800) { /* A high surrogate character is detected, handle especially */ Tcl_UniChar low = *chPtr; - size_t len = Tcl_UtfToUniChar(src, &low); + if (src <= srcEnd-3) { + Tcl_UtfToUniChar(src, &low); + } if ((low & 0xFC00) != 0xDC00) { *dst++ = (char) (((*chPtr >> 12) | 0xE0) & 0xEF); *dst++ = (char) (((*chPtr >> 6) | 0x80) & 0xBF); *dst++ = (char) ((*chPtr | 0x80) & 0xBF); continue; - } else if (pureNullMode == 1) { - int full = (((*chPtr & 0x3FF) << 10) | (low & 0x3FF)) + 0x10000; - *dst++ = (char) (((full >> 18) | 0xF0) & 0xF7); - *dst++ = (char) (((full >> 12) | 0x80) & 0xBF); - *dst++ = (char) (((full >> 6) | 0x80) & 0xBF); - *dst++ = (char) ((full | 0x80) & 0xBF); - *chPtr = 0; - src += len; - continue; } } dst += Tcl_UniCharToUtf(*chPtr, dst); diff --git a/generic/tclTomMath.decls b/generic/tclTomMath.decls index 76c0e06..460466a 100644 --- a/generic/tclTomMath.decls +++ b/generic/tclTomMath.decls @@ -76,7 +76,7 @@ declare 16 { } # Removed in 9.0 #declare 17 {deprecated {is private function in libtommath}} { -# mp_err MP_WUR TclBN_mp_div_3(const mp_int *a, mp_int *q, unsigned int *r) +# mp_err TclBN_mp_div_3(const mp_int *a, mp_int *q, unsigned int *r) #} declare 18 { void TclBN_mp_exch(mp_int *a, mp_int *b) @@ -146,7 +146,7 @@ declare 39 { } # Removed in 9.0 #declare 40 {nostub {is private function in libtommath}} { -# mp_err MP_WUR TclBN_mp_sqr(const mp_int *a, mp_int *b) +# mp_err TclBN_mp_sqr(const mp_int *a, mp_int *b) #} declare 41 { mp_err MP_WUR TclBN_mp_sqrt(const mp_int *a, mp_int *b) diff --git a/tests/encoding.test b/tests/encoding.test index 694c07b..8a8f8c3 100644 --- a/tests/encoding.test +++ b/tests/encoding.test @@ -332,12 +332,30 @@ test encoding-15.5 {UtfToUtfProc emoji character input} { list [string length $x] $y } "4 \U1F602" test encoding-15.6 {UtfToUtfProc emoji character output} { - set x \uD83D\uDE02 - set y [encoding convertto utf-8 \uD83D\uDE02] + set x \uDE02\uD83D\uDE02\uD83D + set y [encoding convertto utf-8 \uDE02\uD83D\uDE02\uD83D] binary scan $y H* z list [string length $x] [string length $y] $z -} {2 4 f09f9882} +} {4 10 edb882f09f9882eda0bd} test encoding-15.7 {UtfToUtfProc emoji character output} { + set x \uDE02\uD83D\uD83D + set y [encoding convertto utf-8 \uDE02\uD83D\uD83D] + binary scan $y H* z + list [string length $x] [string length $y] $z +} {3 9 edb882eda0bdeda0bd} +test encoding-15.8 {UtfToUtfProc emoji character output} { + set x \uDE02\uD83D\xE9 + set y [encoding convertto utf-8 \uDE02\uD83D\xE9] + binary scan $y H* z + list [string length $x] [string length $y] $z +} {3 8 edb882eda0bdc3a9} +test encoding-15.9 {UtfToUtfProc emoji character output} { + set x \uDE02\uD83DX + set y [encoding convertto utf-8 \uDE02\uD83DX] + binary scan $y H* z + list [string length $x] [string length $y] $z +} {3 7 edb882eda0bd58} +test encoding-15.10 {UtfToUtfProc emoji character output} { set x \U1F602 set y [encoding convertto utf-8 \U1F602] binary scan $y H* z |
