简体   繁体   English

PHP - 带有特殊字符的 Scandir

[英]PHP - Scandir with special characters

I'm trying to list the files in a certain folder, but some folders have special characters such as a degree symbol.我正在尝试列出某个文件夹中的文件,但某些文件夹具有特殊字符,例如度数符号。 Using scandir () or RecursiveDirectoryIterator errors occur.使用 scandir() 或 RecursiveDirectoryIterator 会发生错误。 I did some tests isolating the folder and removing the special character and it works.我做了一些测试来隔离文件夹并删除特殊字符,它可以工作。 Is there any way to handle this?有没有办法处理这个? I researched and did not find something that works.我研究并没有找到有效的方法。 I tried a few things like using iconv() but nothing worked.我尝试了一些类似使用 iconv() 的方法,但没有任何效果。

Using scandir on folder named "Fornos 1200°C" gives this error "failed to open dir: No such file or directory" Using scandir on folder named "Fornos 1200C" it works.在名为“Fornos 1200°C”的文件夹上使用 scandir 会出现此错误“无法打开目录:没有这样的文件或目录” 在名为“Fornos 1200C”的文件夹上使用 scandir 它可以工作。

I did another test and saved the script with encoding "Windows 1252" and it apparently worked.我做了另一个测试,并使用编码“Windows 1252”保存了脚本,它显然有效。 Before the script was being saved as "UTF8"在脚本被保存为“UTF8”之前

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM