From 4c2d834fca441a8d463e3bd1a06489f0b864cf73 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 15 Feb 2023 07:21:55 +0000 Subject: Ticket [10c2c17c32] follow-up. One output char too much with -failindex. --- generic/tclEncoding.c | 1 + tests/encoding.test | 3 +++ 2 files changed, 4 insertions(+) diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index c5ecc46..c4db314 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -2595,6 +2595,7 @@ Utf32ToUtfProc( && ((ch & ~0x7FF) == 0xD800))) { if (STOPONERROR) { result = TCL_CONVERT_SYNTAX; + ch = 0; break; } } diff --git a/tests/encoding.test b/tests/encoding.test index bbb40d7..916a84a 100644 --- a/tests/encoding.test +++ b/tests/encoding.test @@ -527,6 +527,9 @@ test encoding-16.15 {Utf16ToUtfProc} -body { test encoding-16.16 {Utf16ToUtfProc} -body { encoding convertfrom utf-16le \x00\xDC\x00\xD8 } -result \uDC00\uD800 +test encoding-16.17 {Utf32ToUtfProc} -body { + list [encoding convertfrom -strict -failindex idx utf-32le \x41\x00\x00\x00\x00\xD8\x00\x00\x42\x00\x00\x00] [set idx] +} -result {A 4} test encoding-16.9 { Utf16ToUtfProc, Tcl_UniCharToUtf, surrogate pairs in utf-16 -- cgit v0.12