findstr or grep that autodetects chararacter encoding (UTF-16)

后端 未结 7 1226
遥遥无期
遥遥无期 2021-01-04 08:34

I want to do this:

 findstr /s /c:some-symbol *

or the grep equivalent

 grep -R some-symbol *

but I need

7条回答
  •  情深已故
    2021-01-04 09:18

    Thanks for the suggestions. I was referring to Windows Vista and XP.

    I also discovered this workaround, using free Sysinternals strings.exe:

    C:\> strings -s -b dir_tree_to_search | grep regexp 
    

    Strings.exe extracts all of the strings it finds (from binaries, but works fine with text files too) and prepends each result with a filename and colon, so take that into account in the regexp (or use cut or another step in the pipeline). The -s makes it do a recursive extraction and -b just suppresses the banner message.

    Ultimately I'm still kind of surprised that the flagship searching utilities Gnu grep and findstr don't handle Unicode character encodings natively.

提交回复
热议问题