Overview
| Artifact ID: | a145253983f81c5278f299130b07fa4c82c6d8109167b79690d0106df223b72d |
|---|---|
| Ticket: | bcd1004104651998d1ae99aa6869e249c0ed0019
A change to the system encoding, a stale cached file FsPath object, and an incorrect result |
| User & Date: | pooryorick on 2019-10-22 18:10:35 |
Changes
- comment changed to:
The ext file system has no concept of "encoding": It names a file exactly the sequence of octets it is handed. In the following script, iso8859-1 is used to create a file, and then that same sequence of octets is obtained using <code>glob</code>. Then an FsPath object created under a different system encoding is created and cached. Later on that FsPath object is used under the original system encoding when it shouldn't be. <code><verbatim> set name 登鸛鵲樓 encoding system iso8859-1 # create an iso8859-1-compatible sequence of octets to name the file by. # They happen to be a string encoded in utf-8, but that's irrelevant. set utf8 [encoding convertto utf-8 $name] set chan [open $utf8 w] puts $chan hello close $chan # lassign [glob -directory [pwd] *$utf8*] fname encoding system utf-8 # The sequence of octets is now itself converted to utf-8. Such a file does not # exist, and a FsPath object has been cached. So far so good. puts [list utf-8 [file exists $fname]] ;#-> 0 encoding system iso8859-1 # Here the answer here should be 1, but the FsPath object created under a # previous system encoding is used when it shouldn't be. puts [list iso8859-1 [file exists $fname]] ;# -> 0 # Discard the cached FsPath object, causing a new FsPath to be created using # the (currently correct) system encoding. puts [list iso8859-1 {string range} [file exists [string range $fname 0 end]]] ;# -> 1 </verbatim></code> - login: "pooryorick"
- mimetype: "text/plain"