PHP文件处理;文件夹名称中的特殊字符 [英] PHP file-handling; Special characters in folder names

查看:265
本文介绍了PHP文件处理;文件夹名称中的特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



对于没有瑞典语的文件夹,它可以正常工作。

我使用rename()将文件从一个文件夹移动到另一个文件夹。 ö涉及到字符。

有没有办法解决这个问题? (除了将文件夹名称更改为没有特殊字符的文件名)



网站完全采用utf-8格式...

rename()的手册章节和用户注释。对于应该使用什么编码没有任何说法。无论如何,如果文件系统支持它,应该可以在文件名中使用UTF-8。

这个SO问题 有一个非常聪明的答案,以解决这个。如果您正在使用的字符也可以在 iso-8859中找到,那么这个字符并不是100%纯种的,但是在大多数情况下可能是可行的。

1 ,你也可以尝试简单的 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆