简体   繁体   English

PhpStorm / WinSCP和SFTP的文件名编码错误

[英]Wrong filename encoding with PhpStorm / WinSCP and SFTP

My hoster has disabled FTP so I am forced to use SFTP but I encountered some strange issues with PhpStorm since moving to SFTP. 我的主机已禁用FTP,所以我被迫使用SFTP,但是自从移至SFTP以来,我遇到了PhpStorm的一些奇怪问题。 My filenames sometimes have german umlauts in them like Lösungsblatt or Übungsblatt and usually it was uploaded properly and the host window displayed the files correctly. 我的文件名有时会带有德语变音符号,例如LösungsblattÜbungsblatt ,通常文件上传正确,主机窗口会正确显示文件。 Since I am forced to use SFTP old files on the remote host show up as this 由于我被迫使用远程主机上的SFTP旧文件,因此显示为

在此处输入图片说明

while newly uploaded files display correctly inside PhpStorm. 而新上传的文件可以在PhpStorm中正确显示。 However in WinSCP the old files are displayed correctly as Lösungsblatt-01.pdf etc. but the files which seemed to be uploaded correctly via PhpStorm are broken since they show up as 但是在WinSCP中,旧文件可以正确显示为Lösungsblatt-01.pdf等。但是似乎已通过PhpStorm正确上传的文件却被破坏了,因为它们显示为

在此处输入图片说明

which is basically the other way round. 基本上是相反的。 I do have a feeling that UTF-8 and UTF-16 filenames are being mixed in the process of uploading so I was curious as to how I can setup the IDE to (1) show the filenames in the remote tree properly and (2) upload files properly with the right encoding (not the encoding of the content but the encoding of the filename itself!) 我确实感觉到在上传过程中UTF-8和UTF-16文件名混合在一起,所以我很好奇如何设置IDE以(1)在远程树中正确显示文件名,以及(2)使用正确的编码正确上传文件(不是内容的编码,而是文件名本身的编码!)

In SFTP protocol file names have to be in UTF-8. 在SFTP协议中,文件名必须使用UTF-8。 Though actually that's only since version 4. The older versions did not mandate a specific encoding. 尽管实际上那只是自版本4起。较早的版本并没有要求特定的编码。 So implementations vary. 因此实现方式各不相同。 Some use UTF-8, but many (maybe most) use the default encoding of the system (like the default Windows Ansi encoding). 有些使用UTF-8,但许多(也许大多数)使用系统的默认编码(例如默认的Windows Ansi编码)。

Recent version of WinSCP always use UTF-8, even for servers implementing SFTP version 3 (or older), like the OpenSSH. WinSCP的最新版本始终使用UTF-8,即使对于实施SFTP版本3(或更旧版本)的服务器(如OpenSSH)也是如此。 Actually OpenSSH does not have a view on the encoding. 实际上,OpenSSH没有编码视图。 It uses whatever encoding the underlying system uses. 它使用基础系统使用的任何编码。 As most *nix systems default to UTF-8 these days, it just works. 由于如今大多数* nix系统默认使用UTF-8,因此它可以正常工作。

My guess is that PhpStorm actually uses the default Ansi encoding of Windows (what would be Windows-1252 for "Western languages"). 我的猜测是PhpStorm实际上使用Windows的默认Ansi编码(“西方语言”将是Windows-1252)。 You can force WinSCP to use that too by setting the "UTF-8 encoding for filenames" to "Off". 通过将“文件名的UTF-8编码”设置为“关”,可以强制WinSCP也使用它。 Though you should actually force PhpStorm to use UTF-8. 尽管您实际上应该强制PhpStorm使用UTF-8。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM