Index: generic/tclStringObj.c ================================================================== --- generic/tclStringObj.c +++ generic/tclStringObj.c @@ -67,19 +67,10 @@ static void SetUnicodeObj(Tcl_Obj *objPtr, const Tcl_UniChar *unicode, Tcl_Size numChars); static Tcl_Size UnicodeLength(const Tcl_UniChar *unicode); static void UpdateStringOfString(Tcl_Obj *objPtr); -#if TCL_UTF_MAX > 3 -#define ISCONTINUATION(bytes) (\ - ((bytes)[0] & 0xC0) == 0x80) -#else -#define ISCONTINUATION(bytes) (\ - ((((bytes)[0] & 0xC0) == 0x80) || (((bytes)[0] == '\xED') \ - && (((bytes)[1] & 0xF0) == 0xB0) && (((bytes)[2] & 0xC0) == 0x80)))) -#endif - /* * The structure below defines the string Tcl object type by means of * functions that can be invoked by generic object code. */ @@ -1300,16 +1291,10 @@ } SetStringFromAny(NULL, objPtr); stringPtr = GET_STRING(objPtr); - /* If appended string starts with a continuation byte or a lower surrogate, - * force objPtr to unicode representation. See [7f1162a867] */ - if (bytes && ISCONTINUATION(bytes)) { - Tcl_GetUnicode(objPtr); - stringPtr = GET_STRING(objPtr); - } if (stringPtr->hasUnicode && (stringPtr->numChars+1) > 1) { AppendUtfToUnicodeRep(objPtr, bytes, toCopy); } else { AppendUtfToUtfRep(objPtr, bytes, toCopy); } @@ -1505,17 +1490,10 @@ */ SetStringFromAny(NULL, objPtr); stringPtr = GET_STRING(objPtr); - /* If appended string starts with a continuation byte or a lower surrogate, - * force objPtr to unicode representation. See [7f1162a867] - * This fixes append-3.4, append-3.7 and utf-1.18 testcases. */ - if (ISCONTINUATION(TclGetString(appendObjPtr))) { - Tcl_GetUnicode(objPtr); - stringPtr = GET_STRING(objPtr); - } /* * If objPtr has a valid Unicode rep, then get a Unicode string from * appendObjPtr and append it. */ @@ -3175,13 +3153,11 @@ * Non-empty string rep. Not a pure bytearray, so we won't * create a pure bytearray. */ binary = 0; - if (ov > objv+1 && ISCONTINUATION(TclGetString(objPtr))) { - forceUniChar = 1; - } else if ((objPtr->typePtr) && (objPtr->typePtr != &tclStringType)) { + if ((objPtr->typePtr) && (objPtr->typePtr != &tclStringType)) { /* Prevent shimmer of non-string types. */ allowUniChar = 0; } } } else { Index: tests/append.test ================================================================== --- tests/append.test +++ tests/append.test @@ -70,19 +70,19 @@ set x \uD83D$x } -result \uD83D\uDE02 test append-3.7 {append \xC0 \x80} -constraints testbytestring -body { set x [testbytestring \xC0] string length [append x [testbytestring \x80]] -} -result 2 +} -result 1 test append-3.8 {append \xC0 \x80} -constraints testbytestring -body { set x [testbytestring \xC0] string length $x[testbytestring \x80] -} -result 2 +} -result 1 test append-3.9 {append \xC0 \x80} -constraints testbytestring -body { set x [testbytestring \x80] string length [testbytestring \xC0]$x -} -result 2 +} -result 1 test append-3.10 {append surrogates} -body { set x \uD83D string range $x 0 end append x \uDE02 } -result [string range \uD83D\uDE02 0 end] Index: tests/utf.test ================================================================== --- tests/utf.test +++ tests/utf.test @@ -93,15 +93,15 @@ return $hi\uDE02 } \uD83D\uDE02 test utf-1.16 {Tcl_UniCharToUtf: \xC0 + \x80} testbytestring { set lo [testbytestring \x80] string length [testbytestring \xC0]$lo -} 2 +} 1 test utf-1.17 {Tcl_UniCharToUtf: \xC0 + \x80} testbytestring { set hi [testbytestring \xC0] string length $hi[testbytestring \x80] -} 2 +} 1 test utf-1.18 {Tcl_UniCharToUtf: surrogate pairs from concat} { string cat \uD83D \uDE02 } \uD83D\uDE02 test utf-2.1 {Tcl_UtfToUniChar: low ascii} {