I am having issues with a few Windows users who have non-ASCII user names.
This is affecting several scripts.
I can replicate it by creating temporary folders etc using such characters.
Particularly Cyrillic and Korean characters.
Oddly when I use Sketchup.temp_dir it can return a folder-path that looks at first sight to be wrong:
e.g. …/Антон/… >>> …/
However, when used in File.exist?(…) etc it is taken to be a valid path !
So that works despite it’s odd appearance…
I suspect that it’s the old MSDOS version of the file name ?
My main issue is when I try to use Dir processes.
I need to remember the current working directory - using pwd=Dir.pwd
Then use Dir.chdir(…) to change to a new temporary directory, when some file downloading and processing is done.
Then use Dir.chdir(pwd) to set things as they were.
It fails because the pwd reference substitutes characters as it’s made.
…/Антон/… >>> …/
And it’s always reported as being UTF-8 encoded in every case.
The first chdir is more than likely to work, because of the valid, but oddly referenced, folder-path to the user’s temp folder.
BUT the second chdir to reset things fails - because the pwd string is invalid - the specified folder …/
?????/… can never exist, a
? is an invalid character in a file-path !
Clearly I can trap for that error, but then the user’s current working-directory is foobar !
So my question is, what other way could I establish a reference to a current directory for the reset code ?
Dir seems to be a dead-end because the returned string from pwd is already processed with the
Interestingly if I use Dir.entries… on the folder’s parent folder path it is listed as “
?????”, BUT if I use Dir.glob… it gets listed properly using its Cyrillic name Антон !
So it is possible to see it, but not to get its currentness.
Using IO.read on a temporary text file into which I’ve previously written the current folder-path as a string, also returns the string with
?????, so that doesn’t work either !
Using a cmd shell in Windows to cd to its parent directory and dir a make list shows it correctly named, but of course its currentness is not accessible.
All ideas welcomed…