带有 git-bash 的 Unicode (utf-8) [英] Unicode (utf-8) with git-bash

查看:20
本文介绍了带有 git-bash 的 Unicode (utf-8)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在让 unicode 为 git-bash 工作时遇到了一些麻烦(在 Windows 7 上).我尝试了很多事情都没有成功.虽然,我不太确定是什么原因造成的,所以我可能在错误的方向上工作.

I'm having some trouble getting unicode to work for git-bash (on windows 7). I have tried many things without success. Although, I'm not quite sure what is responsible to for this so i might be working in the wrong direction.

这似乎应该是可能的,因为 cmd.exe 的编码可以更改为带有chcp 65001"的 unicode.

It really seems this should be possible as the encoding for cmd.exe can be changed to unicode with 'chcp 65001'.

以下是我尝试过的一些方法(除了在 GUI 中查看配置选项的明显效果).

Here are some things I've tried (besides the obvious of looking through the configuration options in the GUI).

  1. 在.bashrc"中设置环境变量.我想这行不通是有道理的,因为我认为这是 linux 的事情.'locale' 命令不存在.

  1. Setting environment variables in '.bashrc'. I guess it makes sense this doesn't work since i think it's a linux thing. The 'locale' command does not exist.

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8

  • 从 cmd.exe 开始,使用 'chcp 65001' 将编码更改为 unicode,然后启动 git-bash.这导致我在尝试 cat 我的 unicode 测试文件时获得权限被拒绝.但是,catting 没有 unicode 的文件工作得很好.正如所演示的,退出 cmd.exe 我仍然可以cat"该文件.使用我的默认编码 (437),我可以在 bash 中 cat 文件(没有权限被拒绝,但输出被篡改).

  • Starting out in cmd.exe, changing the encoding to unicode with 'chcp 65001' and then starting up git-bash. This causes me to get a permission denied when trying to cat my unicode test file. However, catting a file without unicode works just fine. As demonstrated, dropping back out to cmd.exe i can still "cat" the file. Using my default encoding (437) i can cat the file in bash (no permission denied but the output is fudged).

    S:>chcp 65001
    Active code page: 65001
    S:>"C:Program Files (x86)Gitinsh.exe" --login -i
    zarac@TOWELIE /z
    cat /s/unicode.txt
    cat: write error: Permission denied
    zarac@TOWELIE /z
    cat /s/nounicode.txt
    abc
    zarac@TOWELIE /z
    L /s/unicode.txt
    -rw-r--r--    1 zarac    Administ        7 May 18 10:30 /s/unicode.txt
    zarac@TOWELIE /z
    whoami
    toweliezarac
    zarac@TOWELIE /z
    exit
    Z:>type S:unicode.txt
    abc£
    

  • 在启动 shell 时使用/U 标志(它不起作用是有道理的,因为它不完全适用于 if-i-understand-correctly,但它与 unicode 有关,所以我尝试了它).

  • Using the /U flag when starting the shell (makes sense that it doesn't work because it's not quite what it's for if-i-understand-correctly, but it has to do with unicode so i tried it).

    C:WindowsSysWOW64cmd.exe /U /C "C:Program Files (x86)Gitinsh.exe" --login -i
    

  • 由于我更喜欢​​使用 Console2,我尝试在 [HKEY_CURRENT_USERConsole] 和 [HKEY_CURRENT_USERConsoleGit Bash 下的 Windows 注册表中添加一个名为 CodePage 的双字值,其值为 65001(十进制)].这似乎与设置 'chcp 65001' 接受它是自动的"具有相同的效果.(http://stackoverflow.com/questions/379240/is-there-a-windows-command-shell-that-will-display-unicode-characters)

  • As I prefer to use Console2, I've tried adding a dword value named CodePage with the value 65001 (decimal) to the windows registry under [HKEY_CURRENT_USERConsole] as well as [HKEY_CURRENT_USERConsoleGit Bash]. This seems to have the same effect as setting 'chcp 65001' accept that it's "automatic". (http://stackoverflow.com/questions/379240/is-there-a-windows-command-shell-that-will-display-unicode-characters)

    JPSoft 的 TCC/LE

    JPSoft's TCC/LE

    PowerCMD

    stackoverflow

    stackoverflow

    duckduckgo

    ixquick/谷歌

    因此,如果可以修复该权限问题,则方法 2 似乎可行.但是,我对几乎任何解决方案都持开放态度,尽管我更喜欢可以使用 Console2(主要是因为它具有漂亮的选项卡功能).也许一种解决方案是设置一个 SSH 服务器,然后使用 Putty/Kitty 连接到它,但那是错误的!;)

    So, method 2 seems viable if that permission issue can be fixed. However, I'm open to pretty much any solution although i prefer if i can use Console2 (due mostly to it's nifty tab feature). Perhaps one solution would be to setup an SSH server and then use Putty/Kitty to connect to it, but that's just wrong! ; )

    附注.有没有 git-bash 的官方文档?

    PS. Is there any official documentation for git-bash?

    推荐答案

    正如 CharlesB 在评论中所说,msysgit 1.7.10 正确处理 unicode.仍然存在一些问题,但我可以确认更新确实解决了我遇到的问题.

    As CharlesB said in a comment, msysgit 1.7.10 handles unicode correctly. There are still a few issues but I can confirm that updating did solve the issue I was having.

    参见:https://github.com/msysgit/msysgit/wiki/Git-for-Windows-Unicode-Support

    这篇关于带有 git-bash 的 Unicode (utf-8)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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