<i>[string length] reports a length of 2 for a single character</i> status still Closed with 4 other changes
by
.
D 2022-03-07T10:14:24.067
J closedate 2459645.92666744
J icomment Just\swondering,\swhat\scharacter\sis\s\\Uade19\s???\s\s\sIt's\s""\swherever\sI\slook\s...\r\n\r\nSaid\sthat,\slet's\sdemonstrate\swith\sanother\sreasonable\scharacter\s💣\s\r\n\r\nIn\sTcl\s8.6:\r\n<pre>\r\n$\stclsh8.6\r\n%\sstring\slength\s💣\r\n2\r\n%\sstring\sindex\s💣\s0\r\n▒\r\n%\sstring\sindex\s💣\s1\r\n▒\r\n</pre>\r\n\r\nIn\sTcl\s8.7:\r\n<pre>\r\n$\stclsh8.7\r\n%\sstring\slength\s💣\r\n2\r\n%\sstring\sindex\s💣\s0\r\n💣\r\n%\sstring\sindex\s💣\s1\r\n</pre>\r\n\r\nThe\sfact\sthat\s"string\slength"\sreturns\s2\scomes\sfrom\sthe\sinternal\sUTF-16\srepresentation\sfor\sstring\sin\sTcl\s8.x,\snot\ssomething\sthat's\strivial\sto\schange.\sYou\scan\schange\sthat\scompiling\sTcl\s8.7\swith\s-DTCL_UTF_MAX=4.\sBut\sthat\shas\seffect\son\sthe\sC-API\susing\sTcl_UniChar,\stherefore\sthis\sis\sonly\sdone\sfor\sTcl\s9.0.\sSince\sthe\sUTF-8\sencoding\sfor\s💣\sis\s0xF0\s0x9F0\sx92\s0xA3,\swhich\scannot\sbe\ssplit,\sthe\scurrent\s8.7\sbehavior\sis\sthe\sbest\spossible\sunder\sthe\sgiven\srestriction.\r\n\r\nSo,\sthis\sbehavior\sis\sas\sdesigned.\sSee\salso\sthe\s"Caveat"\ssection\sof\s[https://core.tcl-lang.org/tips/doc/trunk/tip/389.md|TIP\s#389],\swhich\sexplains\sthis\sbehavior.\sSorry,\sbut\sclosing\s....
J login jan.nijtmans
J mimetype text/x-fossil-wiki
K 141c6f5621e9c9e881f63fbf28c473955b6adae0
U jan.nijtmans
Z deb78273176f594ceb89659faa466742