Re: [請益] 存取 Windows 上的中文檔案

看板PHP作者 (任性)時間14年前 (2010/03/27 22:46), 編輯推噓1(101)
留言2則, 1人參與, 最新討論串5/6 (看更多)
※ 引述《danny0838 (道可道非常道)》之銘言: : ※ 引述《roga (任性)》之銘言: : : 推 danny0838:囧...php取不到windows的正確檔名是windows的問題還php? : : 都有問題. Windows 檔案名稱編碼混雜是問題一, PHP 讀不到是問題二。 : 嗯..如果 php 以跨平台為理想,就應該要設法支援所有OS的完整檔名。 問題出在 http://svn.php.net/viewvc/php/php-src/trunk/win32/readdir.c?view=markup readdir 來自 struct dirent *readdir(DIR *dp) 在 php 內的那個 handler // $dir = opendir("./"); // while (($file = readdir($dir)) !== false) // echo "filename: " . $file . "\n"; 其實是在 DIR *opendir(const char *dir) 內取得 長得像這樣 dp = (DIR *) malloc(sizeof(DIR)); 然後檔案資訊在 dp 內,像是 dp->fileinfo.cFileName 這樣。 但這樣的作法是讀不到 win32 的 unicode 檔案名稱的。 在 php.net 上面有人問了幾個類似的問題 http://bugs.php.net/bug.php?id=46990 http://bugs.php.net/bug.php?id=47096 但結論是 Can't be fixed in 5.2 neither in 5.3. It will work smoothly in 6.x (unicode support). 我在上一篇說的自己寫 extension ,意思就是自己去做 workaround 像是 vlc player 的作法這樣.. http://www1.videolan.org/developers/vlc/doc/doxygen/html/vlc__charset_8h-source.html 縮網址: http://zzb.bz/nvWjj -- The Internet: where men are men, women are men, and children are FBI agents. -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.220.104.63

03/27 23:02, , 1F
那退一步,已知我要的檔名是"消化酶.txt",我應該傳怎樣
03/27 23:02, 1F

03/27 23:02, , 2F
的字串給php程式才能讀到該檔的內容,還是也不行?
03/27 23:02, 2F
※ 編輯: roga 來自: 61.220.104.63 (03/27 23:31)
文章代碼(AID): #1BhXep2O (PHP)
討論串 (同標題文章)
文章代碼(AID): #1BhXep2O (PHP)