UnicodeDecodeError if stdin encoding is not utf-8

UnicodeDecodeError is raised if standard input encoding is not utf-8 (ie. on Windows).
This PR is using `sys.stdin.encoding` to decode input.
Consider what the code would do if `sys.stdin.encoding` was set to ''?