summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorapnadkarni <apnmbx-wits@yahoo.com>2023-02-15 17:27:55 (GMT)
committerapnadkarni <apnmbx-wits@yahoo.com>2023-02-15 17:27:55 (GMT)
commit96e60d29b763fa1c662fb77e731556ddfaf9c912 (patch)
tree5489dfc4e6e19fea7dbd94dafb9378ebb97b416e /generic
parent6aed3e7d3039ffed6d02ae55fa06aa72550a93d2 (diff)
downloadtcl-96e60d29b763fa1c662fb77e731556ddfaf9c912.zip
tcl-96e60d29b763fa1c662fb77e731556ddfaf9c912.tar.gz
tcl-96e60d29b763fa1c662fb77e731556ddfaf9c912.tar.bz2
Start on expanding encoding tests
Diffstat (limited to 'generic')
-rw-r--r--generic/tclEncoding.c41
1 files changed, 19 insertions, 22 deletions
diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c
index 7886910..8cd970f 100644
--- a/generic/tclEncoding.c
+++ b/generic/tclEncoding.c
@@ -2409,32 +2409,29 @@ UtfToUtfProc(
*/
*dst++ = *src++;
- } else if ((UCHAR(*src) == 0xC0) && (src + 1 < srcEnd)
- && (UCHAR(src[1]) == 0x80) && (flags & ENCODING_UTF) && (!(flags & ENCODING_INPUT)
- || PROFILE_STRICT(profile))) {
- /*
- * \xC0\x80 and either strict profile or target is "real" UTF-8
- * - Strict profile - error
- * - Non-strict, real UTF-8 - output \x00
- */
- if (flags & ENCODING_INPUT) {
- /*
- * TODO - should above check not be against STRICT?
- * That would probably break a convertto command that goes
- * from the internal UTF8 to the real UTF8. On the other
- * hand this means, a strict UTF8->UTF8 transform is not
- * possible using this function.
- */
+ }
+ else if ((UCHAR(*src) == 0xC0) && (src + 1 < srcEnd) &&
+ (UCHAR(src[1]) == 0x80) && (flags & ENCODING_UTF) &&
+ (!(flags & ENCODING_INPUT) || PROFILE_STRICT(profile) ||
+ PROFILE_REPLACE(profile))) {
+ /* Special sequence \xC0\x80 */
+ if (PROFILE_STRICT(profile)) {
result = TCL_CONVERT_SYNTAX;
break;
}
- /*
- * Convert 0xC080 to real nulls when we are in output mode,
- * irrespective of the profile.
- */
- *dst++ = 0;
- src += 2;
+ if (PROFILE_REPLACE(profile)) {
+ dst += Tcl_UniCharToUtf(UNICODE_REPLACE_CHAR, dst);
+ src += 1; /* C0, 80 handled in next loop iteration
+ since dst limit has to be checked */
+ } else {
+ /*
+ * Convert 0xC080 to real nulls when we are in output mode,
+ * irrespective of the profile.
+ */
+ *dst++ = 0;
+ src += 2;
+ }
}
else if (!Tcl_UtfCharComplete(src, srcEnd - src)) {
/*