如何使用GNU diff差异utf-16文件? [英] How do I diff utf-16 files with GNU diff?
问题描述
GNU差异似乎不够智能,无法检测和处理UTF-16文件,这让我感到惊讶。我是否缺少明显的命令行选项?有没有好的选择?
GNU diff doesn't seem to be smart enough to detect and handle UTF-16 files, which surprises me. Am I missing an obvious command-line option? Is there a good alternative?
推荐答案
从GNU diff文档中:
From the GNU diff documentation:
处理多字节和可变宽度
字符
Handling Multibyte and Varying-Width Characters
diff,diff3和sdiff将输入的每行
视为一串单字节
字符。在某些情况下,这可能会误处理
多字节字符。
例如,当要求忽略
空格时,diff不会正确忽略
a多字节空格字符。
diff, diff3 and sdiff treat each line of input as a string of unibyte characters. This can mishandle multibyte characters in some cases. For example, when asked to ignore spaces, diff does not properly ignore a multibyte space character.
此外,diff当前假定每个
字节为一列宽,并且此
假设在某些
语言环境中是不正确的,例如,使用UTF-8
编码的语言环境。这会导致
出现问题-b或
diff的-y或--by-by-side选项。
Also, diff currently assumes that each byte is one column wide, and this assumption is incorrect in some locales, e.g., locales that use UTF-8 encoding. This causes problems with the -y or --side-by-side option of diff.
这些问题必须得到解决
,而不会过度影响实用程序在
单字节环境中的
性能。
These problems need to be fixed without unduly affecting the performance of the utilities in unibyte environments.
IBM GNU / Linux技术中心
国际化团队已提出
一些补丁程序以支持
国际化差异
http://oss.software.ibm.com/developer/opensource/linux/patches/i18n/diffutils-2.7.2-i18n-0.1.patch .gz 。
不幸的是,这些补丁是
不完整的,并且是较早版本的diff的
,因此在此区域
需要做更多的工作。
The IBM GNU/Linux Technology Center Internationalization Team has proposed some patches to support internationalized diff http://oss.software.ibm.com/developer/opensource/linux/patches/i18n/diffutils-2.7.2-i18n-0.1.patch.gz. Unfortunately, these patches are incomplete and are to an older version of diff, so more work needs to be done in this area.
我从没意识到自己。
如果非自由,非命令行工具可以完成这项工作,同时仍在寻找免费的命令行工具:
It looks like Guiffy could to the job if a nonfree, non-command line tool will do the job, still looking for a freeware command line tool:
http://www.guiffy.com/Diff-Tool.html
这篇关于如何使用GNU diff差异utf-16文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!