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.