Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3c3ebea410 | ||
|
|
d307130311 | ||
|
|
59f20f23bd | ||
|
|
c0d3b18e36 | ||
|
|
77a24f6300 | ||
|
|
aabe2cbb33 | ||
|
|
1391eda7db | ||
|
|
776820c81f | ||
|
|
cb0acd5a7d | ||
|
|
4717ea14fd | ||
|
|
05de893f6f | ||
|
|
e0f543167d | ||
|
|
e9f9cac4be | ||
|
|
e9e4041670 | ||
|
|
3185a0b150 | ||
|
|
a2a0ca2a17 | ||
|
|
b19862400b | ||
|
|
a5055aa3db | ||
|
|
2ceb66085c | ||
|
|
e59865fa40 | ||
|
|
02131d1f1b | ||
|
|
08666ed474 | ||
|
|
b488f3edf6 |
@@ -166,11 +166,12 @@ can consume in a single call.
|
||||
.PP
|
||||
\fBTcl_UniCharToUtf\fR stores the character \fIch\fR as a UTF-8 string
|
||||
in starting at \fIbuf\fR. The return value is the number of bytes stored
|
||||
in \fIbuf\fR. If ch is a high surrogate (range U+D800 - U+DBFF), then
|
||||
the return value will be 1 and a single byte in the range 0xF0 - 0xF4
|
||||
will be stored. If you still want to produce UTF-8 output for it (even
|
||||
though knowing it's an illegal code-point on its own), just call
|
||||
\fBTcl_UniCharToUtf\fR again specifying ch = -1.
|
||||
in \fIbuf\fR. The character \fIch\fR can be or'ed with the value TCL_COMBINE
|
||||
to enable special behavior, compatible with Tcl 8.x. Then, if ch is a high
|
||||
surrogate (range U+D800 - U+DBFF), the return value will be 1 and a single
|
||||
byte in the range 0xF0 - 0xF4 will be stored. If \fIch\fR is a low surrogate
|
||||
(range U+DC00 - U+DFFF), an attempt is made to combine the result with
|
||||
the earlier produced bytes, resulting in a 4-byte UTF-8 byte sequence.
|
||||
.PP
|
||||
\fBTcl_UtfToUniChar\fR reads one UTF-8 character starting at \fIsrc\fR
|
||||
and stores it as a Tcl_UniChar in \fI*chPtr\fR. The return value is the
|
||||
|
||||
@@ -835,6 +835,13 @@ typedef struct Tcl_DString {
|
||||
#define TCL_INDEX_NULL_OK 32
|
||||
#define TCL_INDEX_TEMP_TABLE 64
|
||||
|
||||
/*
|
||||
* Flags that may be passed to Tcl_UniCharToUtf.
|
||||
* TCL_COMBINE Combine surrogates
|
||||
*/
|
||||
|
||||
#define TCL_COMBINE 0x1000000
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------------
|
||||
* Flag values passed to Tcl_RecordAndEval, Tcl_EvalObj, Tcl_EvalObjv.
|
||||
|
||||
@@ -1430,9 +1430,11 @@ StringIndexCmd(
|
||||
char buf[4] = "";
|
||||
|
||||
end = Tcl_UniCharToUtf(ch, buf);
|
||||
#if TCL_UTF_MAX < 4
|
||||
if ((ch >= 0xD800) && (end < 3)) {
|
||||
end += Tcl_UniCharToUtf(-1, buf + end);
|
||||
}
|
||||
#endif
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj(buf, end));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4016,6 +4016,14 @@ extern const TclStubs *tclStubsPtr;
|
||||
# define Tcl_UtfToUniChar Tcl_UtfToChar16
|
||||
# undef Tcl_UniCharLen
|
||||
# define Tcl_UniCharLen Tcl_Char16Len
|
||||
# undef Tcl_UniCharToUtf
|
||||
# if defined(USE_TCL_STUBS)
|
||||
# define Tcl_UniCharToUtf(c, p) \
|
||||
(tclStubsPtr->tcl_UniCharToUtf((c)|TCL_COMBINE, (p)))
|
||||
# else
|
||||
# define Tcl_UniCharToUtf(c, p) \
|
||||
((Tcl_UniCharToUtf)((c)|TCL_COMBINE, (p)))
|
||||
# endif
|
||||
#if !defined(BUILD_tcl)
|
||||
# undef Tcl_NumUtfChars
|
||||
# define Tcl_NumUtfChars TclNumUtfChars
|
||||
|
||||
+12
-9
@@ -2316,7 +2316,6 @@ UtfToUtfProc(
|
||||
}
|
||||
dst += Tcl_UniCharToUtf(ch, dst);
|
||||
} else {
|
||||
int low;
|
||||
const char *saveSrc = src;
|
||||
size_t len = TclUtfToUCS4(src, &ch);
|
||||
if ((len < 2) && (ch != 0) && !(flags & TCL_ENCODING_NOCOMPLAIN)
|
||||
@@ -2334,13 +2333,20 @@ UtfToUtfProc(
|
||||
*dst++ = (char) (((ch >> 10) & 0x3F) | 0x80);
|
||||
ch = (ch & 0x0CFF) | 0xDC00;
|
||||
}
|
||||
goto cesu8;
|
||||
#if TCL_UTF_MAX < 4
|
||||
cesu8:
|
||||
#endif
|
||||
*dst++ = (char) (((ch >> 12) | 0xE0) & 0xEF);
|
||||
*dst++ = (char) (((ch >> 6) | 0x80) & 0xBF);
|
||||
*dst++ = (char) ((ch | 0x80) & 0xBF);
|
||||
continue;
|
||||
#if TCL_UTF_MAX < 4
|
||||
} else if ((ch | 0x7FF) == 0xDFFF) {
|
||||
/*
|
||||
* A surrogate character is detected, handle especially.
|
||||
*/
|
||||
|
||||
low = ch;
|
||||
int low = ch;
|
||||
len = (src <= srcEnd-3) ? TclUtfToUCS4(src, &low) : 0;
|
||||
|
||||
if (((low & ~0x3FF) != 0xDC00) || (ch & 0x400)) {
|
||||
@@ -2350,15 +2356,12 @@ UtfToUtfProc(
|
||||
src = saveSrc;
|
||||
break;
|
||||
}
|
||||
cesu8:
|
||||
*dst++ = (char) (((ch >> 12) | 0xE0) & 0xEF);
|
||||
*dst++ = (char) (((ch >> 6) | 0x80) & 0xBF);
|
||||
*dst++ = (char) ((ch | 0x80) & 0xBF);
|
||||
continue;
|
||||
goto cesu8;
|
||||
}
|
||||
src += len;
|
||||
dst += Tcl_UniCharToUtf(ch, dst);
|
||||
ch = low;
|
||||
#endif
|
||||
} else if (!Tcl_UniCharIsUnicode(ch)) {
|
||||
if (!(flags & TCL_ENCODING_NOCOMPLAIN)) {
|
||||
result = TCL_CONVERT_UNKNOWN;
|
||||
@@ -2667,7 +2670,7 @@ Utf16ToUtfProc(
|
||||
if (ch && ch < 0x80) {
|
||||
*dst++ = (ch & 0xFF);
|
||||
} else {
|
||||
dst += Tcl_UniCharToUtf(ch, dst);
|
||||
dst += Tcl_UniCharToUtf(ch | TCL_COMBINE, dst);
|
||||
}
|
||||
src += sizeof(unsigned short);
|
||||
}
|
||||
|
||||
@@ -5132,9 +5132,11 @@ TEBCresume(
|
||||
TclNewObj(objResultPtr);
|
||||
} else {
|
||||
slength = Tcl_UniCharToUtf(ch, buf);
|
||||
#if TCL_UTF_MAX < 4
|
||||
if ((ch >= 0xD800) && (slength < 3)) {
|
||||
slength += Tcl_UniCharToUtf(-1, buf + slength);
|
||||
}
|
||||
#endif
|
||||
objResultPtr = Tcl_NewStringObj(buf, slength);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -869,6 +869,7 @@ TclParseBackslash(
|
||||
* No hexdigits -> This is just "u".
|
||||
*/
|
||||
result = 'u';
|
||||
#if TCL_UTF_MAX < 4
|
||||
} else if (((result & 0xFC00) == 0xD800) && (count == 6)
|
||||
&& (p[5] == '\\') && (p[6] == 'u') && (numBytes >= 10)) {
|
||||
/* If high surrogate is immediately followed by a low surrogate
|
||||
@@ -879,6 +880,7 @@ TclParseBackslash(
|
||||
result = ((result & 0x3FF)<<10 | (low & 0x3FF)) + 0x10000;
|
||||
count += count2 + 2;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case 'U':
|
||||
@@ -888,9 +890,6 @@ TclParseBackslash(
|
||||
* No hexdigits -> This is just "U".
|
||||
*/
|
||||
result = 'U';
|
||||
} else if ((result | 0x7FF) == 0xDFFF) {
|
||||
/* Upper or lower surrogate, not allowed in this syntax. */
|
||||
result = 0xFFFD;
|
||||
}
|
||||
break;
|
||||
case '\n':
|
||||
@@ -954,10 +953,12 @@ TclParseBackslash(
|
||||
*readPtr = count;
|
||||
}
|
||||
count = Tcl_UniCharToUtf(result, dst);
|
||||
#if TCL_UTF_MAX < 4
|
||||
if ((result >= 0xD800) && (count < 3)) {
|
||||
/* Special case for handling high surrogates. */
|
||||
count += Tcl_UniCharToUtf(-1, dst + count);
|
||||
}
|
||||
#endif
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,9 +70,14 @@ static void SetUnicodeObj(Tcl_Obj *objPtr,
|
||||
static size_t 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
|
||||
|
||||
|
||||
/*
|
||||
@@ -2124,10 +2129,12 @@ Tcl_AppendFormatToObj(
|
||||
goto error;
|
||||
}
|
||||
length = Tcl_UniCharToUtf(code, buf);
|
||||
#if TCL_UTF_MAX < 4
|
||||
if ((code >= 0xD800) && (length < 3)) {
|
||||
/* Special case for handling high surrogates. */
|
||||
length += Tcl_UniCharToUtf(-1, buf + length);
|
||||
}
|
||||
#endif
|
||||
segment = Tcl_NewStringObj(buf, length);
|
||||
Tcl_IncrRefCount(segment);
|
||||
allocSegment = 1;
|
||||
@@ -4182,14 +4189,6 @@ ExtendUnicodeRepWithString(
|
||||
dst = stringPtr->unicode + numOrigChars;
|
||||
if (numAppendChars-- > 0) {
|
||||
bytes += TclUtfToUniChar(bytes, &unichar);
|
||||
#if TCL_UTF_MAX > 3
|
||||
/* join upper/lower surrogate */
|
||||
if (bytes && (stringPtr->unicode[numOrigChars - 1] | 0x3FF) == 0xDBFF && (unichar | 0x3FF) == 0xDFFF) {
|
||||
stringPtr->numChars--;
|
||||
unichar = ((stringPtr->unicode[numOrigChars - 1] & 0x3FF) << 10) + (unichar & 0x3FF) + 0x10000;
|
||||
dst--;
|
||||
}
|
||||
#endif
|
||||
*dst++ = unichar;
|
||||
while (numAppendChars-- > 0) {
|
||||
bytes += TclUtfToUniChar(bytes, &unichar);
|
||||
|
||||
+19
-7
@@ -208,15 +208,23 @@ Invalid(
|
||||
*---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#undef Tcl_UniCharToUtf
|
||||
int
|
||||
Tcl_UniCharToUtf(
|
||||
int ch, /* The Tcl_UniChar to be stored in the
|
||||
* buffer. */
|
||||
* buffer. Can be or'ed with flag TCL_COMBINE */
|
||||
char *buf) /* Buffer in which the UTF-8 representation of
|
||||
* the Tcl_UniChar is stored. Buffer must be
|
||||
* large enough to hold the UTF-8 character
|
||||
* (at most 4 bytes). */
|
||||
{
|
||||
#if TCL_UTF_MAX > 3
|
||||
int flags = ch;
|
||||
#endif
|
||||
|
||||
if (ch >= TCL_COMBINE) {
|
||||
ch &= (TCL_COMBINE - 1);
|
||||
}
|
||||
if ((unsigned)(ch - 1) < (UNICODE_SELF - 1)) {
|
||||
buf[0] = (char) ch;
|
||||
return 1;
|
||||
@@ -228,7 +236,11 @@ Tcl_UniCharToUtf(
|
||||
return 2;
|
||||
}
|
||||
if (ch <= 0xFFFF) {
|
||||
if ((ch & 0xF800) == 0xD800) {
|
||||
if (
|
||||
#if TCL_UTF_MAX > 3
|
||||
(flags & TCL_COMBINE) &&
|
||||
#endif
|
||||
((ch & 0xF800) == 0xD800)) {
|
||||
if (ch & 0x0400) {
|
||||
/* Low surrogate */
|
||||
if (((buf[0] & 0xC0) == 0x80) && ((buf[1] & 0xCF) == 0)) {
|
||||
@@ -377,7 +389,7 @@ Tcl_Char16ToUtfDString(
|
||||
/* Special case for handling high surrogates. */
|
||||
p += Tcl_UniCharToUtf(-1, p);
|
||||
}
|
||||
len = Tcl_UniCharToUtf(*w, p);
|
||||
len = Tcl_UniCharToUtf(*w | TCL_COMBINE, p);
|
||||
p += len;
|
||||
if ((*w >= 0xD800) && (len < 3)) {
|
||||
len = 0; /* Indication that high surrogate was found */
|
||||
@@ -1348,7 +1360,7 @@ Tcl_UtfToUpper(
|
||||
* char to dst if its size is <= the original char.
|
||||
*/
|
||||
|
||||
if ((len < TclUtfCount(upChar)) || ((upChar & ~0x7FF) == 0xD800)) {
|
||||
if (len < TclUtfCount(upChar)) {
|
||||
memmove(dst, src, len);
|
||||
dst += len;
|
||||
} else {
|
||||
@@ -1401,7 +1413,7 @@ Tcl_UtfToLower(
|
||||
* char to dst if its size is <= the original char.
|
||||
*/
|
||||
|
||||
if ((len < TclUtfCount(lowChar)) || ((lowChar & ~0x7FF) == 0xD800)) {
|
||||
if (len < TclUtfCount(lowChar)) {
|
||||
memmove(dst, src, len);
|
||||
dst += len;
|
||||
} else {
|
||||
@@ -1451,7 +1463,7 @@ Tcl_UtfToTitle(
|
||||
len = TclUtfToUCS4(src, &ch);
|
||||
titleChar = Tcl_UniCharToTitle(ch);
|
||||
|
||||
if ((len < TclUtfCount(titleChar)) || ((titleChar & ~0x7FF) == 0xD800)) {
|
||||
if (len < TclUtfCount(titleChar)) {
|
||||
memmove(dst, src, len);
|
||||
dst += len;
|
||||
} else {
|
||||
@@ -1467,7 +1479,7 @@ Tcl_UtfToTitle(
|
||||
lowChar = Tcl_UniCharToLower(lowChar);
|
||||
}
|
||||
|
||||
if ((len < TclUtfCount(lowChar)) || ((lowChar & ~0x7FF) == 0xD800)) {
|
||||
if (len < TclUtfCount(lowChar)) {
|
||||
memmove(dst, src, len);
|
||||
dst += len;
|
||||
} else {
|
||||
|
||||
+26
-23
@@ -40,7 +40,10 @@ testConstraint testbytestring [llength [info commands testbytestring]]
|
||||
testConstraint teststringbytes [llength [info commands teststringbytes]]
|
||||
testConstraint exec [llength [info commands exec]]
|
||||
testConstraint testgetencpath [llength [info commands testgetencpath]]
|
||||
|
||||
testConstraint fullutf [expr {[format %c 0x010000] ne "\uFFFD"}]
|
||||
testConstraint utf32 [expr {[testConstraint fullutf]
|
||||
&& [string length [format %c 0x10000]] == 1}]
|
||||
|
||||
# TclInitEncodingSubsystem is tested by the rest of this file
|
||||
# TclFinalizeEncodingSubsystem is not currently tested
|
||||
|
||||
@@ -336,74 +339,74 @@ test encoding-15.3 {UtfToUtfProc null character input} teststringbytes {
|
||||
} c080
|
||||
test encoding-15.4 {UtfToUtfProc emoji character input} -body {
|
||||
set x \xED\xA0\xBD\xED\xB8\x82
|
||||
set y [encoding convertfrom utf-8 \xED\xA0\xBD\xED\xB8\x82]
|
||||
set y [encoding convertfrom -nocomplain utf-8 \xED\xA0\xBD\xED\xB8\x82]
|
||||
list [string length $x] $y
|
||||
} -result "6 😂"
|
||||
} -result "6 \uD83D\uDE02"
|
||||
test encoding-15.5 {UtfToUtfProc emoji character input} {
|
||||
set x \xF0\x9F\x98\x82
|
||||
set y [encoding convertfrom utf-8 \xF0\x9F\x98\x82]
|
||||
list [string length $x] $y
|
||||
} "4 😂"
|
||||
test encoding-15.6 {UtfToUtfProc emoji character output} {
|
||||
test encoding-15.6 {UtfToUtfProc emoji character output} utf32 {
|
||||
set x \uDE02\uD83D\uDE02\uD83D
|
||||
set y [encoding convertto -nocomplain utf-8 \uDE02\uD83D\uDE02\uD83D]
|
||||
binary scan $y H* z
|
||||
list [string length $y] $z
|
||||
} {10 edb882f09f9882eda0bd}
|
||||
test encoding-15.7 {UtfToUtfProc emoji character output} {
|
||||
} {12 efbfbdefbfbdefbfbdefbfbd}
|
||||
test encoding-15.7 {UtfToUtfProc emoji character output} utf32 {
|
||||
set x \uDE02\uD83D\uD83D
|
||||
set y [encoding convertto -nocomplain utf-8 \uDE02\uD83D\uD83D]
|
||||
binary scan $y H* z
|
||||
list [string length $x] [string length $y] $z
|
||||
} {3 9 edb882eda0bdeda0bd}
|
||||
test encoding-15.8 {UtfToUtfProc emoji character output} {
|
||||
} {3 9 efbfbdefbfbdefbfbd}
|
||||
test encoding-15.8 {UtfToUtfProc emoji character output} utf32 {
|
||||
set x \uDE02\uD83Dé
|
||||
set y [encoding convertto -nocomplain utf-8 \uDE02\uD83Dé]
|
||||
binary scan $y H* z
|
||||
list [string length $x] [string length $y] $z
|
||||
} {3 8 edb882eda0bdc3a9}
|
||||
test encoding-15.9 {UtfToUtfProc emoji character output} {
|
||||
} {3 8 efbfbdefbfbdc3a9}
|
||||
test encoding-15.9 {UtfToUtfProc emoji character output} utf32 {
|
||||
set x \uDE02\uD83DX
|
||||
set y [encoding convertto -nocomplain utf-8 \uDE02\uD83DX]
|
||||
binary scan $y H* z
|
||||
list [string length $x] [string length $y] $z
|
||||
} {3 7 edb882eda0bd58}
|
||||
test encoding-15.10 {UtfToUtfProc high surrogate character output} {
|
||||
} {3 7 efbfbdefbfbd58}
|
||||
test encoding-15.10 {UtfToUtfProc high surrogate character output} utf32 {
|
||||
set x \uDE02é
|
||||
set y [encoding convertto -nocomplain utf-8 \uDE02é]
|
||||
binary scan $y H* z
|
||||
list [string length $x] [string length $y] $z
|
||||
} {2 5 edb882c3a9}
|
||||
test encoding-15.11 {UtfToUtfProc low surrogate character output} {
|
||||
} {2 5 efbfbdc3a9}
|
||||
test encoding-15.11 {UtfToUtfProc low surrogate character output} utf32 {
|
||||
set x \uDA02é
|
||||
set y [encoding convertto -nocomplain utf-8 \uDA02é]
|
||||
binary scan $y H* z
|
||||
list [string length $x] [string length $y] $z
|
||||
} {2 5 eda882c3a9}
|
||||
test encoding-15.12 {UtfToUtfProc high surrogate character output} {
|
||||
} {2 5 efbfbdc3a9}
|
||||
test encoding-15.12 {UtfToUtfProc high surrogate character output} utf32 {
|
||||
set x \uDE02Y
|
||||
set y [encoding convertto -nocomplain utf-8 \uDE02Y]
|
||||
binary scan $y H* z
|
||||
list [string length $x] [string length $y] $z
|
||||
} {2 4 edb88259}
|
||||
test encoding-15.13 {UtfToUtfProc low surrogate character output} {
|
||||
} {2 4 efbfbd59}
|
||||
test encoding-15.13 {UtfToUtfProc low surrogate character output} utf32 {
|
||||
set x \uDA02Y
|
||||
set y [encoding convertto -nocomplain utf-8 \uDA02Y]
|
||||
binary scan $y H* z
|
||||
list [string length $x] [string length $y] $z
|
||||
} {2 4 eda88259}
|
||||
test encoding-15.14 {UtfToUtfProc high surrogate character output} {
|
||||
} {2 4 efbfbd59}
|
||||
test encoding-15.14 {UtfToUtfProc high surrogate character output} utf32 {
|
||||
set x \uDE02
|
||||
set y [encoding convertto -nocomplain utf-8 \uDE02]
|
||||
binary scan $y H* z
|
||||
list [string length $x] [string length $y] $z
|
||||
} {1 3 edb882}
|
||||
test encoding-15.15 {UtfToUtfProc low surrogate character output} {
|
||||
} {1 3 efbfbd}
|
||||
test encoding-15.15 {UtfToUtfProc low surrogate character output} utf32 {
|
||||
set x \uDA02
|
||||
set y [encoding convertto -nocomplain utf-8 \uDA02]
|
||||
binary scan $y H* z
|
||||
list [string length $x] [string length $y] $z
|
||||
} {1 3 eda882}
|
||||
} {1 3 efbfbd}
|
||||
test encoding-15.16 {UtfToUtfProc: Invalid 4-byte UTF-8, see [ed29806ba]} {
|
||||
set x \xF0\xA0\xA1\xC2
|
||||
set y [encoding convertfrom -nocomplain utf-8 \xF0\xA0\xA1\xC2]
|
||||
|
||||
+12
-10
@@ -34,6 +34,8 @@ testConstraint testindexobj [expr {[info commands testindexobj] ne {}}]
|
||||
testConstraint testevalex [expr {[info commands testevalex] ne {}}]
|
||||
testConstraint utf32 [expr {[string length \U010000] == 1}]
|
||||
testConstraint testbytestring [llength [info commands testbytestring]]
|
||||
testConstraint utf32 [expr {[testConstraint fullutf]
|
||||
&& [string length [format %c 0x10000]] == 1}]
|
||||
|
||||
# Used for constraining memory leak tests
|
||||
testConstraint memory [llength [info commands memory]]
|
||||
@@ -1946,13 +1948,13 @@ test string-21.22.$noComp {string trimright, unicode} {
|
||||
run {string trimright "\uF602Hello world!\uF602" \uD83D\uDE02}
|
||||
} "\uF602Hello world!\uF602"
|
||||
test string-21.23.$noComp {string trim, unicode} {
|
||||
run {string trim "\uD83D\uDE02Hello world!\uD83D\uDE02" \uD93D\uDE02}
|
||||
run {string trim "\uD83D\uDE02Hello world!\uD83D\uDE02" \uD93D}
|
||||
} "\uD83D\uDE02Hello world!\uD83D\uDE02"
|
||||
test string-21.24.$noComp {string trimleft, unicode} {
|
||||
run {string trimleft "\uD83D\uDE02Hello world!\uD83D\uDE02" \uD93D\uDE02}
|
||||
} "\uD83D\uDE02Hello world!\uD83D\uDE02"
|
||||
test string-21.25.$noComp {string trimright, unicode} {
|
||||
run {string trimright "\uD83D\uDE02Hello world!\uD83D\uDE02" \uD93D\uDE02}
|
||||
run {string trimright "\uD83D\uDE02Hello world!\uD83D\uDE02" \uD93D}
|
||||
} "\uD83D\uDE02Hello world!\uD83D\uDE02"
|
||||
|
||||
test string-22.1.$noComp {string wordstart} -body {
|
||||
@@ -2116,24 +2118,24 @@ test string-24.15.$noComp {string reverse command - pure bytearray} {
|
||||
binary scan [run {tcl::string::reverse [binary format H* 010203]}] H* x
|
||||
set x
|
||||
} 030201
|
||||
test string-24.16.$noComp {string reverse command - surrogates} {
|
||||
test string-24.16.$noComp {string reverse command - surrogates} utf32 {
|
||||
run {string reverse \u0444bulb\uD83D\uDE02}
|
||||
} \uD83D\uDE02blub\u0444
|
||||
test string-24.17.$noComp {string reverse command - surrogates} {
|
||||
} \uDE02\uD83Dblub\u0444
|
||||
test string-24.17.$noComp {string reverse command - surrogates} utf32 {
|
||||
run {string reverse \uD83D\uDE02hello\uD83D\uDE02}
|
||||
} \uD83D\uDE02olleh\uD83D\uDE02
|
||||
test string-24.18.$noComp {string reverse command - surrogates} {
|
||||
} \uDE02\uD83Dolleh\uDE02\uD83D
|
||||
test string-24.18.$noComp {string reverse command - surrogates} utf32 {
|
||||
set s \u0444bulb\uD83D\uDE02
|
||||
# shim shimmery ...
|
||||
string index $s 0
|
||||
run {string reverse $s}
|
||||
} \uD83D\uDE02blub\u0444
|
||||
test string-24.19.$noComp {string reverse command - surrogates} {
|
||||
} \uDE02\uD83Dblub\u0444
|
||||
test string-24.19.$noComp {string reverse command - surrogates} utf32 {
|
||||
set s \uD83D\uDE02hello\uD83D\uDE02
|
||||
# shim shimmery ...
|
||||
string index $s 0
|
||||
run {string reverse $s}
|
||||
} \uD83D\uDE02olleh\uD83D\uDE02
|
||||
} \uDE02\uD83Dolleh\uDE02\uD83D
|
||||
|
||||
test string-25.1.$noComp {string is list} {
|
||||
run {string is list {a b c}}
|
||||
|
||||
+5
-5
@@ -78,11 +78,11 @@ test utf-1.11 {Tcl_UniCharToUtf: 3 byte sequence, low surrogate} testbytestring
|
||||
test utf-1.12 {Tcl_UniCharToUtf: 4 byte sequence, high/low surrogate} {pairsTo4bytes testbytestring} {
|
||||
expr {"\uD842\uDC42" eq [testbytestring \xF0\xA0\xA1\x82]}
|
||||
} 1
|
||||
test utf-1.13.0 {Tcl_UniCharToUtf: Invalid surrogate} {Uesc ucs2} {
|
||||
test utf-1.13.0 {Tcl_UniCharToUtf: Invalid surrogate} Uesc {
|
||||
expr {"\UD842" eq "\uD842"}
|
||||
} 1
|
||||
test utf-1.13.1 {Tcl_UniCharToUtf: Invalid surrogate} {fullutf testbytestring} {
|
||||
expr {"\UD842" eq [testbytestring \xEF\xBF\xBD]}
|
||||
expr {"\UD842" eq [testbytestring \xED\xA1\x82]}
|
||||
} 1
|
||||
test utf-1.14 {Tcl_UniCharToUtf: surrogate pairs from concat} {
|
||||
set lo \uDE02
|
||||
@@ -1114,7 +1114,7 @@ test utf-11.6 {Tcl_UtfToUpper beyond U+FFFF} fullutf {
|
||||
test utf-11.7 {Tcl_UtfToUpper beyond U+FFFF} fullutf {
|
||||
string toupper 𐐨
|
||||
} 𐐀
|
||||
test utf-11.8 {Tcl_UtfToUpper low/high surrogate)} {
|
||||
test utf-11.8 {Tcl_UtfToUpper low/high surrogate)} utf32 {
|
||||
string toupper \uDC24\uD824
|
||||
} \uDC24\uD824
|
||||
|
||||
@@ -1133,7 +1133,7 @@ test utf-12.4 {Tcl_UtfToLower} {
|
||||
test utf-12.5 {Tcl_UtfToLower Georgian (new in Unicode 11)} {
|
||||
string tolower აᲐ
|
||||
} აა
|
||||
test utf-12.6 {Tcl_UtfToLower low/high surrogate)} {
|
||||
test utf-12.6 {Tcl_UtfToLower low/high surrogate)} utf32 {
|
||||
string tolower \uDC24\uD824
|
||||
} \uDC24\uD824
|
||||
test utf-12.7 {Tcl_UtfToLower beyond U+FFFF} fullutf {
|
||||
@@ -1161,7 +1161,7 @@ test utf-13.5 {Tcl_UtfToTitle Georgian (new in Unicode 11)} {
|
||||
test utf-13.6 {Tcl_UtfToTitle Georgian (new in Unicode 11)} {
|
||||
string totitle Აა
|
||||
} Აა
|
||||
test utf-13.7 {Tcl_UtfToTitle low/high surrogate)} {
|
||||
test utf-13.7 {Tcl_UtfToTitle low/high surrogate)} utf32 {
|
||||
string totitle \uDC24\uD824
|
||||
} \uDC24\uD824
|
||||
test utf-13.8 {Tcl_UtfToTitle beyond U+FFFF} fullutf {
|
||||
|
||||
Reference in New Issue
Block a user