SVN 错误:无法将字符串从本机编码转换为“UTF-8" [英] SVN Error: Can't convert string from native encoding to 'UTF-8'
问题描述
我有一个提交后钩子脚本,当提交到存储库时,它会执行工作副本的 SVN 更新.
I've got a post-commit hook script that performs a SVN update of a working copy when commits are made to the repository.
当用户使用 TortoiseSVN 从他们的 Windows 机器提交到存储库时,他们收到以下错误:
When users commit to the repository from their Windows machines using TortoiseSVN they get the following error:
post-commit hook failed (exit code 1) with output:
svn: Error converting entry in directory '/home/websites/devel/website/guides/Images' to UTF-8
svn: Can't convert string from native encoding to 'UTF-8':
svn: Teneriffa-S?195?188d.jpg
上面有问题的文件是:Teneriffa-Süd.jpg
注意带重音的 u.这是因为该站点是德语并且文件已用德语拼写.
The file in question above is: Teneriffa-Süd.jpg
notice the accented u. This is because the site is German and the files have been spelt in German.
在 Linux 命令行中对工作副本执行更新时,不会遇到任何错误.上述错误仅在 Windows SVN 客户端通过提交执行 post-commit 钩子时存在.
When executing a update on the working copy at the Linux command-line no errors are encountered. The above error only exists when the post-commit hook is executed via a commit by a Windows SVN client.
问题:
- 为什么 SVN 会尝试更改文件的编码?
- 文件名是否允许包含 Windows 标准 ASCII 字符之外的字符?
<小时>
更新:
事实证明,当从 Windows 机器(通过 Samba)查看时,相关文件的文件名正确显示为 Teneriffa-Süd.jpg
但当我从 Linux 服务器(使用 SSH)查看文件名时和 PuTTY) 文件所在的位置我得到 Teneriffa-Süd.jpg
It turns out that the file in question's filename correctly displays as Teneriffa-Süd.jpg
when viewed from a Windows machine (via Samba) but when I view the filename from the Linux server (using SSH and PuTTY) where the file resides I get Teneriffa-Süd.jpg
推荐答案
- 它不会改变文件的编码.它更改了文件名的编码(希望每个客户都能理解).
- 谁允许的?NTFS 使用 16 位代码点,Windows 可以根据您要求的方式以各种编码公开文件名(它会尝试将它们转换为您要求的编码).现在......那一点(你怎么问)取决于你使用的特定 svn 客户端.在我看来,这像是 TortoiseSVN 中的一个错误.
编辑添加:
呃.我误解了症状.svn 服务器以 utf-8 格式存储所有内容(似乎它成功地做到了).
Ugh. I misunderstood the symptoms. the svn server stores everything in utf-8 (and it seems that it did that successfully).
提交后钩子是无法从 UTF-8 转换的位.如果我理解你的意思,服务器上的提交后钩子会触发对共享驱动器的 svn 更新(因此 svn 服务器启动了一个 svn 客户端到自己......)?这意味着需要修复的配置是客户端在服务器上的配置.在执行 svn 服务器的环境中检查 LANG/LC_ALL..碰巧的是,钩子在 真空环境(见提示).所以你应该在钩子本身中设置变量.
The post-commit hook is the bit that fails to convert from UTF-8. If I understand what you're saying correctly, the post-commit hook on the server triggers an svn update to a shared drive (the svn server therefore starts an svn client to itself...) ? This means that the configuration that needs to be fixed is the one for the client on the server.
Check the LANG / LC_ALL on the environment executing the svn server.. As it happens, the hooks are run in a vacuum environment (see Tip). So you should set the variable in the hook itself.
另请参阅此页面了解如何svn 处理本地化
See also this page for info on how svn handles localisation
这篇关于SVN 错误:无法将字符串从本机编码转换为“UTF-8"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!