“svnlook changed”编码 [英] "svnlook changed" encoding

查看:244
本文介绍了“svnlook changed”编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我执行以下命令:



svnlook changed {path} -r {rev} p>

其中{path}是存储库路径,{rev}是修订版本号,我得到以下输出:



U trunk / this / is / a / path / Mon fichier avec un nom accentu,.txt



输出应该是:



U trunk / this / is / a / path / Mon fichier avec un nomaccentué.txt



é和其他重音字元无法正确显示...



方法为svnlook正确输出字符?



我知道我可以使用svn log与--xml选项,以获得正确的编码,但我需要这个



感谢

解决方案

这里的问题是你的预提交挂钩是由Subversion二进制运行的,出于安全原因,传递一个空环境到挂钩脚本。在空的环境中的事情是删除任何特定的区域设置,恢复到系统默认(通常是C或类似的东西)。



获得正确的输出从 svnlook ,您需要在运行它之前恢复您关心的环境。如果您的脚本是bash,可能是:

 #!/ bin / bash 

export LANG =en_US.UTF-8
export PATH =/ bin:/ usr / bin

#运行svnlook并获取UTF-8编码输出

通常,任何带有'.UTF-8'后缀的语言环境都应该是正确的。鉴于您似乎是一个法语人,'fr_FR.UTF-8'语言环境将是一个合理的设置。


When I execute the following command:

svnlook changed {path} -r {rev}

where {path} is the repository path and {rev} is the revision number, I get the following output:

U trunk/this/is/a/path/Mon fichier avec un nom accentu,.txt

The output should actually be:

U trunk/this/is/a/path/Mon fichier avec un nom accentué.txt

The "é" and other accentuated characters are not shown properly...

Is there any way for svnlook to output characters properly?

I know I can use "svn log" with the "--xml" option to get the proper encoding , but I need this for a pre-commit hook, and svn.exe can only get information from revisions, not transactions.

Thanks

解决方案

The issue you have here is that your pre-commit hook is run by the Subversion binary, which for security reasons passes an empty environment to the hook script. Among the things an empty environment does is remove any specific locale settings, reverting you to the system default (usually 'C' or something similar).

To get the correct output from svnlook, you need to restore the environment you care about before running it. If your script is bash, perhaps something like:

#!/bin/bash

export LANG="en_US.UTF-8"
export PATH="/bin:/usr/bin"

# Run svnlook here and get UTF-8 encoded output

In general, any locale with the '.UTF-8' suffix should be fine. Given that you appear to be a French speaker, the 'fr_FR.UTF-8' locale would be a reasonable setting.

这篇关于“svnlook changed”编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆