Fix UTF8 detection in some circumstances

e.g. on a typical Ubuntu installation setlocale() could return
something like: "LC_CTYPE=en_US.UTF-8;LC_NUMERIC=en_US.UTF-8;..."
etc. Without the patch this is not recognized as UTF8.

This fixes an issue with left/right arrow keys in the REPL if
Unicode characters are present.
fix spurious test failure on a system that happened to have an executable named 'foo' in the PATH
Merge remote-tracking branch 'upstream/master' into deparse