使用PHP将文件写入Windows,其中包含文件名中的日文字符(Use PHP to write a file to Windows that contains Japanese characters

编程入门 行业动态 更新时间:2024-10-28 12:26:42
使用PHP将文件写入Windows,其中包含文件名中的日文字符(Use PHP to write a file to Windows that contains Japanese characters in the filename)

我想使用文件名中的日文字符将文件保存到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

更多推荐

本文发布于:2023-07-05 15:54:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1039177.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:日文   文件名   字符   其中包含   文件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!