summaryrefslogtreecommitdiffstats
path: root/generic/tclEncoding.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclEncoding.c')
-rw-r--r--generic/tclEncoding.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c
index 0ce75b4..3d5e474 100644
--- a/generic/tclEncoding.c
+++ b/generic/tclEncoding.c
@@ -2288,7 +2288,7 @@ BinaryProc(
*/
#if TCL_MAJOR_VERSION > 8 || defined(TCL_NO_DEPRECATED)
-# define STOPONERROR !(flags & TCL_ENCODING_NOCOMPLAIN)
+# define STOPONERROR (!(flags & TCL_ENCODING_NOCOMPLAIN) || (flags & TCL_ENCODING_STOPONERROR))
#else
# define STOPONERROR (flags & TCL_ENCODING_STOPONERROR)
#endif
@@ -2359,11 +2359,18 @@ UtfToUtfProc(
*dst++ = *src++;
} else if ((UCHAR(*src) == 0xC0) && (src + 1 < srcEnd)
- && (UCHAR(src[1]) == 0x80) && !(flags & TCL_ENCODING_MODIFIED)) {
+ && (UCHAR(src[1]) == 0x80) && (!(flags & TCL_ENCODING_MODIFIED) || ((flags & TCL_ENCODING_STRICT) == TCL_ENCODING_STRICT))) {
/*
- * Convert 0xC080 to real nulls when we are in output mode.
+ * If in input mode, and -strict is specified: This is an error.
*/
+ if (flags & TCL_ENCODING_MODIFIED) {
+ result = TCL_CONVERT_UNKNOWN;
+ break;
+ }
+ /*
+ * Convert 0xC080 to real nulls when we are in output mode, with or without '-strict'.
+ */
*dst++ = 0;
src += 2;
} else if (!Tcl_UtfCharComplete(src, srcEnd - src)) {