thanks for looking into this. I understand that changing standard I/O behaviour in ExifTool would be quite a tough job. Should you ever get to implement it, I would support John's suggestion of introducing an i/o abstraction layer.
As you have mentioned, the problem is not Perl specific, however the Windows C stdio has native support for unicode filenames (via wfopen) for more than a decade now. That way it is actually quite easy to write cross platform C code that has (optional) UTF-16 file name support.
I had a look into the C sources for Perl recently, hoping to find some sort of a wfopen() implemented, but it's 8-bit characters everywhere...
With regard to alternatives, we have experimented with all kinds of workarounds, including 8.3 "DOS" filenames, soft and hard links and passing files via stdin. The only solution that worked in all cases was to copy the file to and from a temporary location for reading and writing, which is an expensive operation.
I am going to describe how this was done in the hope that others might find it useful:
In this case, the most important decision when dealing with temporary files is whether or not the file needs to be renamed prior to opening it in ExifTool. No temp file is necessary if the path and name of the current file can be safely represented as an 8-bit ANSI string.
Due to the codepage system, there is no static set of convertible characters for any given system. ExifTool might be perfectly fine opening a file with a Japanese name on a Japanese codepage system, but may or may not open the file on a system with a chinese code page.
So in order to minimize the number of file renames, I wrote the following Win32 C++ function that determines file name compatibility:
For those using C#:
If the above function fails, files need to be renamed prior to opening with ExifTool. Alternatively you could use a simple CreateFileA() in C and see if it succeeds.
There is one last workaround in my mind that does not require temporary files: if you could add an option to write the modified image to stdout, we could use the following in Windows:
I am piping a file into stdin and redirect stdout to a file. Off course this could include error handling if used from within another program.Thanks!