在 Windows 上更正 linux 文件名的脚本,反之亦然?
据我所知,类Unix系统使用UTF-8来编码文件名,而Windows系统使用自己的Windows单字节编码。
我经常处理带有日语文件名的档案。当我打开在 Windows 中创建的此类存档时,日文字母已失效,因为文件名编码不正确。
当我在 Linux 中创建存档然后有人在 Windows 下打开它时,也会发生同样的情况。
所以,我认为这应该是一个很常见的问题,而且,因为文件名是可恢复的,所以必须已经存在纠正 .sh 脚本(适用于 Linux)和 .bat 脚本(适用于 Windows)。
但在谷歌搜索了很长一段时间后我仍然没有找到任何东西。 有这样的脚本吗?如果不是,什么困难可能阻止人们创造它们?
更新 我很高兴有一个适用于大多数 Linux 系统和大多数 Windows 系统的解决方案。
As far as I know, Unix-like systems use UTF-8 for encoding filenames, while Windows system use their own Windows single-byte encodings.
I am working with archives with japanese filenames in them quite oftenly. When I open such archive created in Windows, japanese letters are dead, because filename encoding is incorrect.
Same thing happens, when I create archive in my Linux and then someone opens it under Windows.
So, I have thought that this should be quite common problem, and, because filenames are recoverable there must already exist correcting .sh script for linux and .bat script for Windows.
But after googling for quite a long time I still have not found anything.
Is there such scripts at all? If not, what difficultuies may have stopped people from creating them?
Update
I would be happy with a solution that works for most Linux systems and most Windows systems.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Windows 使用两字节编码 UTF-16。您的问题很可能是您正在使用您正在使用的任何存档工具的单字节 ANSI 版本。
除非您提供有关您正在使用的代码和工具的更多详细信息,否则很难给出具体的建议。但是,在现代 Windows 文件系统中使用全部 Unicode 字符没有限制。
Windows uses the two byte encoding UTF-16. Your problem is most likely that you are using single byte ANSI versions of whatever archive tool you are using.
Until you give more details of the code and tools you are using it's hard to give specific advice. However, the are no limitations on using the full range of Unicode characters in modern Windows file systems.
感谢您的意见。对于简单的 bash 脚本来说,案例确实看起来相当复杂,我需要使用编程语言。
我没有看到类似“关闭问题”按钮的内容,因此我将使用此答案来执行此操作。
Thank you for your input. Case indeed looks quite complex for simple bash script, I'll need to use programming language.
I don't see anything like "close question" button, so I'll use this answer to do so.
查看 convmv 工具适用于 Unix 系统
Take a look to convmv tool available for Unix systems