1

So, I have a little code, which uses locates files using an RecursiveDiectoryIterator and a RecursiveIteratorIterator to locate all the files in the directory. And I then check to see if the file exists, for some files it does not...

$fromIterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir,FilesystemIterator::UNIX_PATHS | FilesystemIterator::SKIP_DOTS));

foreach ($fromIterator as $file)
{
    if (!file_exists($file->getPathname()))
        print $file->getPathname() . "does not exist...\n";
}

I get some files like: TÜBITAK_UEKAE_Kök_Sertifika_Hizmet_Saglayicisi_Sürüm_3.txt does not exist...

Is there something special I need to do to handle these filenames?

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
RedBullet
  • 501
  • 6
  • 18
  • Some reading for you - http://evertpot.com/filesystem-encoding-and-php/. TL;DR - Windows is terrible. If this is for local development, I recommend a Vagrant LAMP box – Phil Feb 24 '14 at 02:12
  • possible duplicate of [PHP: How to create unicode filenames](http://stackoverflow.com/questions/6467501/php-how-to-create-unicode-filenames) – Phil Feb 24 '14 at 02:14
  • I did see that thread, not creating a filename. Trying to use en existing filename PHP already found... – RedBullet Feb 24 '14 at 02:35

1 Answers1

1

Since you are dealing with special characters, I suspect you are using UTF-8 encoding.

I don't think file_exists() will handle UTF-8 input properly. Try to use file_exists(utf8_decode(...)) instead.

Havenard
  • 27,022
  • 5
  • 36
  • 62