PHP文件处理;文件夹名称中的特殊字符 [英] PHP file-handling; Special characters in folder names
问题描述
对于没有瑞典语的文件夹,它可以正常工作。
我使用rename()将文件从一个文件夹移动到另一个文件夹。 ö涉及到字符。
有没有办法解决这个问题? (除了将文件夹名称更改为没有特殊字符的文件名)
网站完全采用utf-8格式...
这个SO问题 有一个非常聪明的答案,以解决这个。如果您正在使用的字符也可以在 iso-8859中找到,那么这个字符并不是100%纯种的,但是在大多数情况下可能是可行的。
utf8_decode()
。但是这个解决方案并不完整,也不完美,因为它会在地图外面的字符上失败。 I am using rename() to move a file from one folder to another with php.
It works fine with folders which don't have the swedish å ä ö characters involved.
Is there any way around this? (except for changing the folder names to something without special chars)
The website is entirely in utf-8 format...
This seems to be a bit of a grey area looking at the the manual chapter on rename()
and the User Contributed Notes. There is no word on what encoding should be used. Anyway, if the filesystem supports it, it should be possible to use UTF-8 in file names.
This SO question has a very clever answer to work around this. It's not 100% pure-bred, but probably workable in most cases.
If the characters you are using are also available in iso-8859-1
, you could also try a simple utf8_decode()
. But that solution is not complete and not perfect, as it will fail on characters outside the map.
这篇关于PHP文件处理;文件夹名称中的特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!