Overview
| Artifact ID: | c32fe6722c1e74a0ff593e43f9c7b676d8273463fccf68cae7387b4aaa897405 |
|---|---|
| Ticket: | 141c6f5621e9c9e881f63fbf28c473955b6adae0
[string length] reports a length of 2 for a single character |
| User & Date: | jan.nijtmans on 2022-03-07 10:13:40 |
Changes
- assignee changed to: "jan.nijtmans"
- closedate changed to: "2459645.92615994"
- closer changed to: "jan.nijtmans"
- icomment:
Just wondering, what character is \Uade19 ??? It's "" wherever I look ... Said that, let's demonstrate with another reasonable character 💣 In Tcl 8.6: <pre> $ tclsh8.6 % string length 💣 2 % string index 💣 0 ▒ % string index 💣 1 ▒ </pre> In Tcl 8.7: <pre> $ tclsh8.7 % string length 💣 2 % string index 💣 0 💣 % string index 💣 1 </pre> The fact that "string length" returns 2 comes from the internal UTF-16 representation for string in Tcl 8.x, not something that's trivial to change. You can change that compiling Tcl 8.7 with -DTCL_UTF_MAX=4. But that has effect on the C-API using Tcl_UniChar, therefore this is only done for Tcl 9.0. Since the UTF-8 encoding for 💣 is 0xF0 0x9F0 x92 0xA3, which cannot be split, the current 8.7 behavior is the best possible under the given restriction. So, this behavior is as designed. See also the "Caveat" section of [https://core.tcl-lang.org/tips/doc/trunk/tip/389.md|TIP #389], which explains this behavior. Sorry, but closing ....
- login: "jan.nijtmans"
- mimetype: "text/plain"
- resolution changed to: "Invalid"
- status changed to: "Closed"