php - 重命名不支持多字节字符

标签 php rename multibyte

如果我写:

rename('php109.tmp','test.jpg');

然后就可以正常工作了。

但是如果我把它改成:

rename('php109.tmp','中文.jpg');

它会报告

"No such file or directory...".

但是如果多字节字符可以写入数据库然后可以读出,那么重命名时为什么会失败?

最佳答案

文件系统不一定使用 UTF-8。例如,这就是维基百科关于 NTFS 的说法。 :

NTFS allows any sequence of 16-bit values for name encoding (file names, stream names, index names, etc.). This means UTF-16 codepoints are supported, but the file system does not check whether a sequence is valid UTF-16 (it allows any sequence of short values, not restricted to those in the Unicode standard).

您可能需要使用 iconv()在字符集之间进行转换。

关于php - 重命名不支持多字节字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/873853/

相关文章:

php - move_uploaded_file 无法打开流 : Permission denied - Mac

php - 如何使用 PHP::PDO 执行带变量的 mysql 脚本?

oracle - 如何重命名 Oracle 中的表,以便更新所有外键、约束、触发器和序列并保留任何现有数据?

git mv 记录移动?

php - fatal error : Call to undefined function mb_strtolower() even if mbstring is enabled

php - SQLSTATE[23000] : Integrity constraint violation: 1048 Column 'page_id' cannot be null laravel 5

php - 从数据库中选择行时出错

git - 如何重命名 git 命令

string - UTF8 与 UTF16 与 char* 与什么?有人给我解释一下这个烂摊子!

php - 如何以二进制安全的方式从多字节 PHP 字符串变量中获取单个字节?