As regards Linux, the behaviour can be controlled by with:
(setenv "LANG" ENCODING)
before calling M-x shell and after from the shell buffer with:
(set-buffer-process-coding-system INPUT-ENCODING OUTPUT-ENCODING)
Both should be set to a value compatible with the string to be represented. UTF-8 encoding family should work in most of the cases.