Skip to content
Tcl Source Code Artifact [a145253983]
Login

Artifact [a145253983]

Artifact a145253983f81c5278f299130b07fa4c82c6d8109167b79690d0106df223b72d:

Ticket change [a145253983] - Ticket [bcd1004104651998|bcd1004104] <i>A change to the system encoding, a stale cached file FsPath object, and an incorrect result</i> status still Open with 3 other changes by pooryorick on 2019-10-22 18:10:35.
D 2019-10-22T18:10:35.340
J comment The\sext\sfile\ssystem\shas\sno\sconcept\sof\s"encoding":\s\sIt\snames\sa\sfile\sexactly\sthe\r\nsequence\sof\soctets\sit\sis\shanded.\s\sIn\sthe\sfollowing\sscript,\siso8859-1\sis\sused\sto\r\ncreate\sa\sfile,\sand\sthen\sthat\ssame\ssequence\sof\soctets\sis\sobtained\susing\r\n<code>glob</code>.\s\sThen\san\sFsPath\sobject\screated\sunder\sa\sdifferent\ssystem\r\nencoding\sis\screated\sand\scached.\s\sLater\son\sthat\sFsPath\sobject\sis\sused\sunder\sthe\r\noriginal\ssystem\sencoding\swhen\sit\sshouldn't\sbe.\r\n\r\n<code><verbatim>\r\nset\sname\s\s登鸛鵲樓\r\n\r\nencoding\ssystem\siso8859-1\r\n\r\n#\screate\san\siso8859-1-compatible\ssequence\sof\soctets\sto\sname\sthe\sfile\sby.\r\n#\sThey\shappen\sto\sbe\sa\sstring\sencoded\sin\sutf-8,\sbut\sthat's\sirrelevant.\r\nset\sutf8\s[encoding\sconvertto\sutf-8\s$name]\r\n\r\nset\schan\s[open\s$utf8\sw]\r\nputs\s$chan\shello\r\nclose\s$chan\r\n\r\n#\r\nlassign\s[glob\s-directory\s[pwd]\s*$utf8*]\sfname\r\n\r\n\r\n\r\nencoding\ssystem\sutf-8\r\n\r\n#\sThe\ssequence\sof\soctets\sis\snow\sitself\sconverted\sto\sutf-8.\sSuch\sa\sfile\sdoes\snot\r\n#\sexist,\sand\sa\sFsPath\sobject\shas\sbeen\scached.\s\sSo\sfar\sso\sgood.\r\nputs\s[list\sutf-8\s[file\sexists\s$fname]]\s;#->\s0\r\nencoding\ssystem\siso8859-1\r\n\r\n#\sHere\sthe\sanswer\shere\sshould\sbe\s1,\sbut\sthe\sFsPath\sobject\screated\sunder\sa\r\n#\sprevious\ssystem\sencoding\sis\sused\swhen\sit\sshouldn't\sbe.\r\nputs\s[list\siso8859-1\s[file\sexists\s$fname]]\s\s;#\s->\s0\r\n\r\n#\sDiscard\sthe\scached\sFsPath\sobject,\scausing\sa\snew\sFsPath\sto\sbe\screated\susing\r\n#\sthe\s(currently\scorrect)\ssystem\sencoding.\r\nputs\s[list\siso8859-1\s{string\srange}\s[file\sexists\s[string\srange\s$fname\s0\send]]]\s\s;#\s->\s1\r\n</verbatim></code>
J login pooryorick
J mimetype text/plain
K bcd1004104651998d1ae99aa6869e249c0ed0019
U pooryorick
Z 41e1aa0e05d77eb36f1a32100168254e