diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2022-11-30 11:11:28 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2022-11-30 11:11:28 (GMT) |
commit | 4d235898611fe66668632c48acbe44e9c86de509 (patch) | |
tree | 645d763018361e93343272d49054dac1e06c1ad4 /generic/tclEncoding.c | |
parent | 5cb9dc5ddc24459e55fab2188d60c867755e6f40 (diff) | |
parent | a7d6b92abf2f95c2c8478c3bd79ee9da76c6d717 (diff) | |
download | tcl-4d235898611fe66668632c48acbe44e9c86de509.zip tcl-4d235898611fe66668632c48acbe44e9c86de509.tar.gz tcl-4d235898611fe66668632c48acbe44e9c86de509.tar.bz2 |
Merge 8.7. This also fixes [133456085a]
Diffstat (limited to 'generic/tclEncoding.c')
-rw-r--r-- | generic/tclEncoding.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index 3013916..5a516f3 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -568,7 +568,7 @@ TclInitEncodingSubsystem(void) type.nullSize = 1; type.clientData = INT2PTR(TCL_ENCODING_UTF); Tcl_CreateEncoding(&type); - type.clientData = INT2PTR(0); + type.clientData = INT2PTR(TCL_ENCODING_NOCOMPLAIN); type.encodingName = "cesu-8"; Tcl_CreateEncoding(&type); @@ -577,13 +577,13 @@ TclInitEncodingSubsystem(void) type.freeProc = NULL; type.nullSize = 2; type.encodingName = "ucs-2le"; - type.clientData = INT2PTR(TCL_ENCODING_LE); + type.clientData = INT2PTR(TCL_ENCODING_LE|TCL_ENCODING_NOCOMPLAIN); Tcl_CreateEncoding(&type); type.encodingName = "ucs-2be"; - type.clientData = INT2PTR(0); + type.clientData = INT2PTR(TCL_ENCODING_NOCOMPLAIN); Tcl_CreateEncoding(&type); type.encodingName = "ucs-2"; - type.clientData = INT2PTR(isLe.c); + type.clientData = INT2PTR(isLe.c|TCL_ENCODING_NOCOMPLAIN); Tcl_CreateEncoding(&type); type.toUtfProc = Utf32ToUtfProc; @@ -2408,15 +2408,16 @@ UtfToUtfProc( dst += Tcl_UniCharToUtf(ch, dst); ch = low; #endif - } else if (!Tcl_UniCharIsUnicode(ch)) { - if (STOPONERROR) { - result = TCL_CONVERT_UNKNOWN; - src = saveSrc; - break; - } - if (!(flags & TCL_ENCODING_MODIFIED)) { - ch = 0xFFFD; - } + } else if (STOPONERROR && !(flags & TCL_ENCODING_MODIFIED) && !Tcl_UniCharIsUnicode(ch) + && (((ch & ~0x7FF) == 0xD800) || ((flags & TCL_ENCODING_STRICT) == TCL_ENCODING_STRICT))) { + result = TCL_CONVERT_UNKNOWN; + src = saveSrc; + break; + } else if (((flags & TCL_ENCODING_STRICT) == TCL_ENCODING_STRICT) + && (flags & TCL_ENCODING_MODIFIED) && !Tcl_UniCharIsUnicode(ch)) { + result = TCL_CONVERT_SYNTAX; + src = saveSrc; + break; } dst += Tcl_UniCharToUtf(ch, dst); } |