<i>A change to the system encoding, a stale cached file FsPath object, and an incorrect result</i>.
by
.
D 2019-10-22T14:27:51.183
J assignee nobody
J closer nobody
J cmimetype text/x-fossil-wiki
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#\sA\sfile\snamed\sby\sthat\ssequence\sof\soctets\sexists.\s\r\nputs\s[list\siso8859-1\s[file\sexists\s$fname]]\s;#->\s1\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 is_private 0
J login pooryorick
J priority 5\sMedium
J resolution None
J severity Important
J status Open
J submitter pooryorick
J subsystem 37.\sFile\sSystem
J title A\schange\sto\sthe\ssystem\sencoding,\sa\sstale\scached\sfile\sFsPath\sobject,\sand\san\sincorrect\sresult
J type Bug
K bcd1004104651998d1ae99aa6869e249c0ed0019
U pooryorick
Z 4ba45342088c105df61cd43efe0ffd4a