.
D 2020-04-30T15:27:56.798
J icomment \r\nThe\strickiest\sissue\shere\sis\sthat\sTcl\sstrings\shave\stwo\suses.\r\n\r\nFirst,\sthey\sare\sa\sway\sto\sstore\sand\sprocess\stext,\sand\sfor\sthat\spurpose\r\nincreased\sUnicode\sconformance\sis\sthe\sgood\sway\sto\smove\sthe\r\ncapabilities\sof\sTcl\sprogramming\sinto\sagreement\swith\sthe\sexpectations\r\nof\stext\sprogramming\sin\sother\slanguages.\r\n\r\nHowever,\sTcl\sstrings\sare\salso\sthe\scommon\sfoundation\sof\sall\svalues\sin\r\nthe\slanguage.\s\s"Everything\sis\sa\sstring".\s\sIf\swe\sremove\ssome\sof\sthe\r\nalphabet\swe\scan\suse\sto\smake\sup\sthose\sstrings,\swe\sare\sremoving\ssome\r\nof\sthe\sexpressible\svalues\sin\sthat\srepresentation\sset,\swhich\scan\slead\r\nto\strouble.\r\n\r\nThe\ssame\sissue\scame\sup\sin\sthe\s8.0\s->\s8.1\stransition.\s\sIn\s8.0\s"Everything\r\nis\sa\sstring"\smeant\s"Everything\sis\srepresentable\sas\sa\ssequence\sof\sbytes",\r\nand\sin\sorder\sto\ssupport\sall\svalues,\sTcl\s8.0\swas\swritten\sto\ssupport\sstrings\r\ncovering\sthat\sentire\sset\sof\ssequences\sof\sany\sbyte\svalue.\r\n\r\nWhen\s8.1\scame\sout,\sthe\snew\ssupport\sfor\sinternational\scharacter\ssets\r\nbrought\swith\sit\sa\snew\srule\sthat\sthe\s"string"\svalues\swere\sconceptually\r\n"Any\ssequence\sof\sUCS-2\scharacters",\sand\swhen\slooking\sat\r\n(char\s*)\sarguments\ssomething\ssimilar\sto\sUTF-8\swould\sbe\sused\sto\r\nencode\sthat\sconcept.\r\n\r\nThis\schange\smeant\sthat\sat\sleast\sfor\ssome\scommands,\sscript\swriters\r\nhad\sto\sbecome\saware\sof\sthe\sdistinction\sbetween\s"bytes"\sand\s"chars".\r\nUsing\sthe\sC\sroutines\sproperly\sdemanded\seven\smore\sawareness.\r\n\r\nIf\ssome\suser\sof\sTcl\s8.0\swas\saccustomed\sto\spassing\sthe\sbytes\r\n"\\xC2\\x80"\sto\sTcl\sand\shave\sthem\sreliably\streated\sand\spreserved\r\nas\sa\ssequence\sof\stwo\sthings,\sTcl\s8.1\sbroke\sthat\scontract,\sbecause\r\nlarge\sparts\sof\sTcl\snow\ssaw\sand\streated\sthat\sas\sU+0080.\sTo\smake\r\nup\sfor\sit,\sTcl\s8.1\sprovided\sbytearrays,\sso\sthat\sanyone\sneeding\sto\r\nsend\sarbitrary\sbyte\ssequences\sinto\sTcl\sfree\sfrom\scorruption\shad\r\na\sway\sto\sdo\sit.\r\n\r\nIn\sparallel\swith\sthat,\sI\sthink\sif\swe\srevise\sour\sstring\sdefinition\sto\r\nexclude\sthe\s\sUCS-2\scharacters\sthat\sare\ssurrogates\sin\sUTF-16,\r\nwe\slikewise\sneed\ssome\snew\sfacility\sso\sthat\sany\sTcl\susers\sthat\r\nhave\sneed\sto\swork\swith\sUCS-2\sarrays\scan\scontinue\sto\sdo\sso.\r\n\r\nI\sthink\sthere's\sat\sleast\ssome\sreason\sto\sbelieve\sUCS-2\sarrays\sare\r\na\sconcept\sTcl\sprogrammers\sneed.\s\sIf\sI\simagine\sreading\sfrom\r\na\schannel\sencoded\sin\sutf-16,\sthere\scan\sbe\sa\spoint\swhere\sI've\r\nread\sthe\shigh\ssurrogate\sbut\snot\syet\sthe\slow\ssurrogate\sthat\sfollows\r\nit.\s\sIn\sthat\smoment,\sI\sneed\sto\sstore\sin\sthe\svariable\sholding\s"what\sI've\r\nread\sso\sfar\sfrom\sthe\schannel"\sa\svalue\sthat\sincludes\san\sunpaired\r\nsurrogate.\s\sJust\slike\sI\scan\scurrently\suse\sa\sbytearray\sto\shold\san\r\nincomplete\sUTF-8\ssequence\spartially\sread\sfrom\sa\sbinary\schannel.\r\n\r\nThis\sprobably\smeans\sexpanding\sthe\sset\sof\sconcepts\sfor\r\nTcl\sprogramming\sto\sinclude\sbytes,\scode\sunits,\sand\scharacters.\r\n\r\nI\sthink\sthe\shistorical\sexample\sof\s8.0\s->\s8.1\sestablishes\sthat\r\nsuch\sa\schange\sis\snot\sabsolutely\sforbidden\sfor\s8.7,\sbut\sit\sis\r\na\schange\sof\sremarkable\sscale\sand\spotential\sfor\sdisruption.\r\nIf\swe\scontemplate\sit,\sI\sthink\swe\sare\sobligated\sto\ssupply\sclear\r\nmigration\ssupports\sand\shigh\squality\sadvice\show\sto\snavigate\sit.\r\n\r\nDoes\sthat\smake\ssense?
J login dgp
J mimetype text/plain
K 5dabd088eecefd81cf86cf213a2e3e7f25b1329b
U dgp
Z 3432eb4187cc700e9c763187db6115d9