命令行重定向在输出中丢失重音

发布于 2024-12-08 11:31:22 字数 400 浏览 0 评论 0原文

我想从我的 svn 项目中获取所有日志并将其输出到文件中。问题是有时笔记是用法语写的,并且有重音“é”、“à”等。

当我使用这个命令时:

svn log svn://mysvnserver/mysite/trunk

dos窗口中的输出很好。口音是存在的。

但是当我将输出重定向到这样的文件时,

svn log svn://mysvnserver/mysite/trunk > C:\releaseNotes.txt

所有重音都会丢失,为什么?

我什至强制文件采用 utf-8 格式,但一旦运行命令行,文件就会强制恢复为 ANSI 格式,从而导致重音符号无法读取。

我应该怎么办?

I want to fetch all logs from my svn project and output it to a file. The problem is that sometimes the notes are written in french and have accents "é", "à", etc.

When I use this command:

svn log svn://mysvnserver/mysite/trunk

the ouput in the dos window is fine. The accents are present.

But when I redirect the output to a file like this

svn log svn://mysvnserver/mysite/trunk > C:\releaseNotes.txt

all accents are lost, why?

I even force the file to be in utf-8 but as soon as I run the command line the file is forced back to ANSI making the accents unreadable.

What should I do?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

追星践月 2024-12-15 11:31:22

首先,Subversion 命令行客户端在 Windows 上显示和处理非 ASCII 字符时存在很多问题。作者认为这不是一个太大的问题,因为显然任何需要处理超过 ASCII 的人都是白痴,特别是如果他们使用的是 Windows。它有时会以奇怪的方式表现出来:

S:\Joey\Wikipedia Work\Flags>svn log "Flag of Čáslav.svg"
svn: 'Flag of Cáslav.svg' is not under version control

...即使文件位于存储库中。很久以前,作者放弃了对非 ASCII 字符的实际支持,而是选择通过去除重音等将所有内容转换为 ASCII/Latin 1 来忽略/解决问题(请注意上面示例中的 Č 与 C)以避免显示问题。我可以尝试再次找到以这种方式关闭的错误报告,但已经有一段时间了。

编辑:使用cmd /u不起作用;重定向的文件仍然只有 CP1252 编码。

我仍在尝试哄TortoiseSVN写入这样的文件,但到目前为止没有取得太大成功,尽管我成功打开了日志窗口。

啊啊,但是,您可以做的是使用--xml选项,然后解析XML以获得您想要的数据。 XML 文件使用 UTF-8 编码并且不会破坏字符。虽然它更复杂,但如果您可以使用 PowerShell,那么根据 XML 复制正常输出应该相当容易。

First of all, the Subversion command-line client has plenty of problems with display and handling of non-ASCII characters on Windows. The authors consider it not too big a problem, because apparently whoever needs to handle more than ASCII is a moron, especially if they're on Windows. It manifests itself in strange ways at times:

S:\Joey\Wikipedia Work\Flags>svn log "Flag of Čáslav.svg"
svn: 'Flag of Cáslav.svg' is not under version control

... even though the file is in the repository. Quite a while back the authors gave up on actually supporting non-ASCII characters and instead chose to ignore/fix the issue by converting everything into ASCII/Latin 1 by stripping accents, etc. (note the Č vs. C in the example above) to side-step display problems. I can try finding the bug report that was closed that way again but it's been a while.

EDIT: Using cmd /u does not work; the redirected file still has only CP1252 encoding.

I am still trying to coax TortoiseSVN into writing such a file but without much success so far, even though I succeeded in opening the log window.

Aaah, what you can do, however, is to use the --xml option and then parse the XML to get the data you want. The XML file uses UTF-8 encoding and doesn't mangle characters. It's more complicated, though, but if you have PowerShell at your disposal, it should be fairly easy to replicate the normal output based on the XML.

夜巴黎 2024-12-15 11:31:22

你知道 chcp DOS 命令吗?

在 svn 登录 bat 文件之前使用它(使用正确的字符集)

Doyou know about chcp DOS-command?

Use it (with correct charset) before svn log in bat-file

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文