在PHP的Filesystem functions中處理UTF-8 FileNames
來解決此問題,請使用urlencode函數將所需的文件夾名稱轉換為URL-SAFE格式,然後再將其傳遞給mkdir:這確保文件夾名稱中的所有字符均已編碼為所有操作系統的有效文件名。要檢索原始的UTF-8文件名,請使用uroldecode。
替代解決方案(帶有警告)Restrict to ISO-8859-1 Characters
Alternatively, limit filenames to characters representable in ISO-8859-1. Use utf8_decode and utf8_encode to convert filenames between UTF-8 and ISO-8859-1.However, these alternatives come with caveats:$dir_name = urlencode("Depósito"); mkdir($dir_name);
Filesystem functions cannot handle bytes that match invalid Windows filesystem characters in ISO-8859-1.
Windows may use非英語環境中的非ISO-8859-1編碼,需要更複雜的轉換。
免責聲明: 提供的所有資源部分來自互聯網,如果有侵犯您的版權或其他權益,請說明詳細緣由並提供版權或權益證明然後發到郵箱:[email protected] 我們會在第一時間內為您處理。
Copyright© 2022 湘ICP备2022001581号-3