I think what's going on here is a failure in file creation to recognize you are using wide characters. I could be wrong here, since the characters you list off should be supported by a normal open (code points 0xd6, 0xe5 and 0xc5). Unfortunately, it seems based on some research I've done (with some guidance from
tye in the CB) that this is not really trivial to deal with. You need to specifically tell Windows that you are trying to create files w/ wide characters in the names. To do this, you need to use the CreateFileW method from
Win32API::File, followed by OsFHandleOpen to retrieve the appropriate file handle. At that point, I believe you should be good to go. There are a good number of PerlMonks nodes on this, so check out
site:www.perlmonks.org createfilew. Of the resultant links, I found
Re^3: Saving file name with Chinese characters useful.
As a side note, your open statements aren't doing what you think: when you say
open MISSING, "+>>$targetDir/$k/$pr/$year/missing.txt" || die "could not open $targetDir/$k/$pr/$year/missing.txt";
the || binds tighter than the list operator (comma), so you will never test if the open succeeded. It's equivalent to
open MISSING, ("+>>$targetDir/$k/$pr/$year/missing.txt" || die "could not open $targetDir/$k/$pr/$year/missing.txt");
which always equivalent to
open MISSING, "+>>$targetDir/$k/$pr/$year/missing.txt";
Since "+>>$targetDir/$k/$pr/$year/missing.txt" evaluates to true. You either need to add parens or use the low-precedence or. See Burned by precedence rules and Operator Precedence and Associativity.