Way to make Emacs' M-x rgrep work with both UTF8 and UTF16 files?

Viewed 173

Is it possible to customize Emacs so that rgrep would correctly find occurrences of some pattern in both UTF8 (or even Latin) and UTF16 files?

I guess we should customize grep-find-template, but can't make my way through it.

EDIT 2017-06-16 I do now have an example of working utf-8/16 cat command for the shell. It should then be transformed for the Emacs's grep, if that's possible. Here it is:

cat $1 | ( [[ $(file -i $1) =~ utf-16be ]] && ( iconv -f UTF-16 -t UTF-8 || true ) || cat )
0 Answers
Related