自动检测字符编码的 findstr 或 grep (UTF-16) [英] findstr or grep that autodetects chararacter encoding (UTF-16)
本文介绍了自动检测字符编码的 findstr 或 grep (UTF-16)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想这样做:
findstr /s /c:some-symbol *
或等价的grep
grep -R some-symbol *
但我需要该实用程序来自动检测以 UTF-16(和朋友)编码的文件并适当地搜索它们.我的文件中甚至有字节顺序标记 FFEE,所以我什至没有寻找英勇的自动检测.
but I need the utility to autodetect files encoded in UTF-16 (and friends) and search them appropriately. My files even have the byte-ordering mark FFEE in them so I'm not even looking for heroic autodetection.
有什么建议吗?
我指的是 Windows Vista 和 XP.
I'm referring to Windows Vista and XP.
推荐答案
一种解决方法是将 UTF-16 转换为 ASCII 或 ANSI
A workaround is to convert your UTF-16 to ASCII or ANSI
TYPE UTF-16.txt > ASCII.txt
然后就可以使用 FINDSTR.
Then you can use FINDSTR.
FINDSTR object ASCII.txt
这篇关于自动检测字符编码的 findstr 或 grep (UTF-16)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文