Serhiy Storchaka added the comment:

> - when stdin is a pipe (ex: echo "abc"|python ...), the stdin encoding 
> becomes cp1252 (ANSI code page) because os.device_encoding(0) returns None; 
> cp1252 is the result of locale.getpreferredencoding(False) (ANSI code page). 
> sys.stdin.readline() does not contain a BOM.

What if echo non-ascii characters? How they are encoded?

Perhaps Python should detect when it is ran under PowerShell in a pipe and set 
stdin (and/or stdout and stderr) encoding to CP65001).

----------
nosy: +serhiy.storchaka

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue21927>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to