[issue21927] BOM appears in stdin when using Powershell
STINNER Victor
report at bugs.python.org
Fri Jul 11 16:27:46 CEST 2014
STINNER Victor added the comment:
See also issues #1602 (Windows console) and #16587 (stdin, _setmode() and wprintf).
I tried msvcrt.setmode(0, 0x40000): set stdin mode to _O_U8TEXT. In this mode, echo "abc"|python -c "import sys; print(ascii(sys.stdin.read()))" displays "\xff\xfea\x00b\x00c\x00\n\x00" which is "abc" encoded to UTF-16 (little endian with the BOM), b'\xff\xfe' is the Unicode BOM U+FEFF (u'\uFEFF') encoded to UTF-16-LE. U+FEFF encoded to UTF-8 gives b'\xef\xbb\xbf'.
So it looks like it's not an issue of the stdin mode. I tried all modes and I always get the Unicode BOM.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21927>
_______________________________________
More information about the Python-bugs-list
mailing list