0

This is driving me crazy. I've read dozens of posts on the problem (on SO and elsewhere), but none of them seem to help me.

I have a directory of files:

file.pdf
another file.pdf
one-more-file.pdf
Корпусные воздухонагреватели.pdf

I want to loop through the files and get their last modified dates. I can successfully loop through the files using opendir or scandir. However when you get to the file with Russian/Cryillic characters... PHP won't get the last modified time. Instead it throws an error message of :

Warning: filemtime() [function.filemtime]: stat failed for ????????? ??????????????????.pdf in test.php on line 27

This is the same error you get when you pass a filename that doesn't exist.

I figure that I need to convert the string from some encoding to another... but everything I've tried with iconv has resulted in the same error.

PHP 5.3 is running on a Windows 7 machine (under Softaculous AMPPS). I can see the file names properly through Windows Explorer on the same machine.

UPDATE

On a whim, I transferred my script and a few of the files to my RedHat Linux server and it works fine there. So I'm guessing this has to either be a PHP, Apache, or Windows setting that is causing the problem.

DragonYen
  • 958
  • 9
  • 22
  • 2
    Could this be anything like [what happened in this other question](http://stackoverflow.com/q/11118990/1167750)? – summea Apr 03 '14 at 19:49
  • It seems you need to use a single byte encoding for the file name in the script and it has to be the same as the non-unicode encoding configured in windows regional settings. – Vatev Apr 03 '14 at 19:59
  • 1
    @summea Yeah, I think you found a post that finally explains why it isn't working... and that I'm not going to be able to fix it. =/ Thanks. – DragonYen Apr 03 '14 at 20:42

0 Answers0