diff options
| author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-03-12 16:10:52 (GMT) |
|---|---|---|
| committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2023-03-12 16:10:52 (GMT) |
| commit | eeee744ee2f72edd36c45a3ee07dbbee39f16994 (patch) | |
| tree | 59850507b809aec84dea02821c1e6a7e3a55cbce /generic/tclEncoding.c | |
| parent | 63b29d841b1918bd77d066db066e4e55eb2f1e0b (diff) | |
| download | tcl-eeee744ee2f72edd36c45a3ee07dbbee39f16994.zip tcl-eeee744ee2f72edd36c45a3ee07dbbee39f16994.tar.gz tcl-eeee744ee2f72edd36c45a3ee07dbbee39f16994.tar.bz2 | |
Minor bug-fix for utf-32: Only throw exception for codepoints > +U10FFFF if "-strict" is specified. Otherwise replace with 0xFFFD
Diffstat (limited to 'generic/tclEncoding.c')
| -rw-r--r-- | generic/tclEncoding.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index 4f334bb..a471fe9 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -2606,19 +2606,17 @@ Utf32ToUtfProc( if ((unsigned)ch > 0x10FFFF) { ch = 0xFFFD; - if (STOPONERROR) { + if ((flags & TCL_ENCODING_STRICT) == TCL_ENCODING_STRICT) { result = TCL_CONVERT_SYNTAX; break; } } else if (((flags & TCL_ENCODING_STRICT) == TCL_ENCODING_STRICT) && ((ch & ~0x7FF) == 0xD800)) { - if (STOPONERROR) { - result = TCL_CONVERT_SYNTAX; + result = TCL_CONVERT_SYNTAX; #if TCL_UTF_MAX < 4 - ch = 0; + ch = 0; #endif - break; - } + break; } /* @@ -2850,7 +2848,7 @@ Utf16ToUtfProc( if (((prev & ~0x3FF) == 0xD800) && ((ch & ~0x3FF) != 0xDC00)) { if (((flags & TCL_ENCODING_STRICT) == TCL_ENCODING_STRICT)) { result = TCL_CONVERT_UNKNOWN; - src -= 2; /* Go back to before the high surrogate */ + src -= 2; /* Go back to beginning of high surrogate */ dst--; /* Also undo writing a single byte too much */ numChars--; break; |
