RedBullet
RedBullet

Reputation: 531

php filenames with international names on windows

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?

Upvotes: 1

Views: 382

Answers (1)

Havenard
Havenard

Reputation: 27884

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.

Upvotes: 1

Related Questions