shell-command-on-region (M-|) does not do the {de,en}coding of I/O to the process as documented.

It says (if I read it correctly) that it will use buffer-file-coding-system (at least unless coding-system-for-{read,write} are set) for output to and input from (if doing substitution with a prefix argument) the process.

However, it "just" calls call-process-region which will use default-process-coding-system rather than buffer-file-coding-system.

To try, 'emacs -q', switch to an empty buffer, and:

  C-x RET f iso-8859-7 RET C-SPC C-u M-| echo -e '\0245' RET

This does not insert a drachma sign.

However, if you run (setq default-process-coding-system '(iso-8859-7 iso-8859-7)) first, it does indeed produce a drachma.

Output encoding works the same way.

- Gustav