2014-02-24 17 views
1

因此,我有一些代碼,它使用RecursiveDiectoryIterator和RecursiveIteratorIterator來定位文件來查找目錄中的所有文件。我然後檢查文件是否存在,對一些人來說並不文件...在Windows上使用國際名稱的php文件名

$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"; 
} 

我得到一些文件,如: TÜBITAK_UEKAE_Kök_Sertifika_Hizmet_Saglayicisi_Sürüm_3.txt不存在...

有什麼我需要處理這些文件名嗎?

+0

有些爲你閱讀 - http://evertpot.com/filesystem-encoding-and-php/。 TL; DR - Windows非常糟糕。如果這是爲了本地開發,我推薦一個Vagrant LAMP框 – Phil

+0

[PHP:如何創建unicode文件名]的可能重複(http://stackoverflow.com/questions/6467501/php-how-to-create-unicode-filenames ) – Phil

+0

我沒看到那個線程,沒有創建一個文件名。試圖使用現有的文件名PHP已經找到... – RedBullet

回答

1

既然您正在處理特殊字符,我懷疑您正在使用UTF-8編碼。

我不認爲file_exists()將正確處理UTF-8輸入。嘗試改爲使用file_exists(utf8_decode(...))

+0

好猜,但沒有影響。 – RedBullet