如何在 Windows 中使用 subversion 操作 unicode 命名的文件? [英] How to manipulate unicode-named files with subversion in Windows?

查看:26
本文介绍了如何在 Windows 中使用 subversion 操作 unicode 命名的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我使用代码页为 950(Big5,繁体中文)的 Windows 7,我想操作一些与 unicode 名称混合的文件,例如 简体中文文件.txt(GB2312,简体中文)svn.

Say I use Windows 7 with code page 950 (Big5, Traditional Chinese), I want to manipulate some files mixed with unicode name such as 简体中文文件.txt (GB2312, Simplified Chinese) with svn.

如果我使用 chcp 950,当我运行时:

If I use chcp 950, when I run:

svn add .\简体中文文件.txt

我收到一个错误:

svn: warning: W155010: 'D:\path\to\work-dir\?体中文文件.txt'
not found
svn: E200009: Could not add all targets because some targets don't exist
svn: E200009: Illegal target for the requested operation

如果我使用 chcp 65001 (UTF-8),我会得到更严重的错误:

If I use chcp 65001 (UTF-8), I get an even worse error:

svn: warning: W155010: 'D:\path\to\work-dir\?体svn: E200009: C
ould not add all targets because some targets don't exist
svn: E200009: Illegal target for the requested operation

我想尝试 chcp 1200 (UCS-LE) 但它说:

I'd like to try chcp 1200 (UCS-LE) but it says:

Invalid code page

似乎 TortoiseSVN 可以正确操作这些文件.但是,我需要编写调用 svn 的脚本来运行多个自动化作业.有什么解决办法吗?

It seems that TortoiseSVN can manipulate those files correctly. However I need to write scripts calling svn to run several automated jobs. Is there any solution available?

推荐答案

使用 C 标准库文件 IO 函数的 MS 实现的 svn 等程序无法读取包含当前代码页之外字符的命令输入或文件名.您必须为每个文件分别chcp 到合适的代码页(例如,中文为 936).

Programs like svn that use the MS implementation of the C standard library's file IO functions cannot read command input or file names containing characters outside the current code page. You would have to chcp to a suitable code page for each file separately (eg 936 for Chinese).

理论上代码页 65001 可以覆盖每个字符,但不幸的是,MS C 运行时存在严重的错误,当使用此代码页时,这些错误通常会破坏应用程序.微软一直未能解决这个长期存在的问题,这让 UTF-8 成为 Windows 下的二等公民.

In theory code page 65001 could cover every character, but unfortunately the MS C runtime has serious bugs that usually break applications when this code page is in use. Microsoft's ongoing failure to fix this long-standing problem leaves UTF-8 a second-class citizen under Windows.

在未来它看起来像 http://subversion.tigris.org/issues/show_bug.cgi?id=1537 应该通过使用直接 Win32 API 而不是 C stdlib 来解决问题,但我看不到相关代码更改的地方是确认控制台输入和文件访问也有类似的处理.

In the future it looks like http://subversion.tigris.org/issues/show_bug.cgi?id=1537 should fix the problem by using direct Win32 APIs instead of C stdlib to do console writes, though I can't see where the related code change is to confirm whether console input and file access are similarly addressed.

这篇关于如何在 Windows 中使用 subversion 操作 unicode 命名的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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