git gui - 是否可以显示UTF16? [英] git gui - can it be made to display UTF16?
问题描述
有没有办法让
我一直在做很多 在msysGit人员的帮助下更好的解决方案,并提出了这个清洁/污迹过滤器。该过滤器使用Gnu文件和iconv命令来确定文件的类型,并将其转换为msysGit的内部UTF-8格式并从中转换。
这种类型的Clean /涂抹过滤器为您提供了更多的灵活性。它应该允许Git在大多数情况下将混合格式文件视为UTF-8文本:diffs,merge,git-grep以及gitattributes属性,如eol-conversion,ident-replacement和内置diff模式。
上述差异过滤器解决方案仅适用于差异,因此受到更多限制。
设置这个过滤器:
- 获取Gnu libiconv ,以及文件,并安装两者。
- 确保GnuWin32 \ bin目录(通常为C:\ Program Files \GnuWin32\bin)位于您的%PATH %
-
将以下内容添加到〜\Git\etc\gitconfig中:
[filtermixedtext]
clean = iconv -sc -f $(文件-b --mime-encoding%f)-t utf-8
smudge = iconv -sc -f utf-8 -t $(file -b --mime-encoding%f)
required
-
在您的全局〜/ Git / etc / gitattributes或本地〜/ .gitattributes中添加一行以处理混合格式文本,例如:
*。txt filter = mixedtext
我已经在包含ANSI,UTF-16和UTF-8格式的sql文件的目录中使用了它。它工作到目前为止。除非出现任何意外,这看起来像20%的努力,可以覆盖所有Windows文本格式问题的80%。
Is there any way to make git gui
display and show diffs for UTF16 files somehow?
I found some information, but this is mostly referring to the command line rather than the gui.
I have been working on a much better solution with help from the msysGit people, and have come up with this clean/smudge filter. The filter uses the Gnu file and iconv commands to determine the type of the file, and convert it to and from msysGit's internal UTF-8 format.
This type of Clean/Smudge Filter gives you much more flexibility. It should allow Git to treat your mixed-format files as UTF-8 text in most cases: diffs, merge, git-grep, as well as gitattributes properties like eol-conversion, ident-replacement, and built-in diff patterns.
The diff filter solution outlined above only works for diffs, and so is much more limited.
To set up this filter:
- Get Gnu libiconv, and file, and install both.
- Ensure that the GnuWin32\bin directory (usually "C:\Program Files\GnuWin32\bin") is in your %PATH%
Add the following to ~\Git\etc\gitconfig:
[filter "mixedtext"] clean = iconv -sc -f $(file -b --mime-encoding %f) -t utf-8 smudge = iconv -sc -f utf-8 -t $(file -b --mime-encoding %f) required
Add a line to your global ~/Git/etc/gitattributes or local ~/.gitattributes to handle mixed format text, for example:
*.txt filter=mixedtext
I have used this on a directory with sql files in ANSI, UTF-16, and UTF-8 formats. It is working so far. Barring any surprises, this looks like the 20% effort that could cover 80% of all Windows text format problems.
这篇关于git gui - 是否可以显示UTF16?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!