我想使用文件名中的日文字符将文件保存到Windows。
PHP文件以UTF-8编码保存
<?php $oldfile = "test.txt"; $newfile = "日本語.txt"; copy($oldfile,$newfile); ?>该文件复制,但在Windows中显示为
æ-¥æœ¬èªž.txt
我如何将它保存为
日本语.TXT
?
I want to save a file to Windows using Japanese characters in the filename.
The PHP file is saved with UTF-8 encoding
<?php $oldfile = "test.txt"; $newfile = "日本語.txt"; copy($oldfile,$newfile); ?>The file copies, but appears in Windows as
日本語.txt
How do I make it save as
日本語.txt
?
最满意答案
我最终使用了https://github.com/kenjiuno/php-wfio中的php-wfio扩展
在将php_wfio.dll放入php \ ext文件夹中并启用扩展名后,我用wfio:// (前两个都需要加前缀,或者您得到一个Cannot rename a file across wrapper types错误)
我的测试代码最终看起来像
<?php $oldfile = "wfio://test.txt"; $newfile = "wfio://日本語.txt"; copy($oldfile,$newfile); ?>并且该文件被保存在Windows中作为日本语.txt,这正是我正在寻找的
I have ended up using the php-wfio extension from https://github.com/kenjiuno/php-wfio
After putting php_wfio.dll into php\ext folder and enabling the extension, I prefixed the filenames with wfio:// (both need to be prefixed or you get a Cannot rename a file across wrapper types error)
My test code ends up looking like
<?php $oldfile = "wfio://test.txt"; $newfile = "wfio://日本語.txt"; copy($oldfile,$newfile); ?>and the file gets saved in Windows as 日本語.txt which is what I was looking for
更多推荐
发布评论