开发者

Command line redirection lose accents in output

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?


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.


Doyou know about chcp DOS-command?

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜