Inada Naoki <songofaca...@gmail.com> added the comment: On Sat, Jun 15, 2019 at 2:43 AM Eryk Sun <rep...@bugs.python.org> wrote: > > Eryk Sun <eryk...@gmail.com> added the comment: > > > # Power Shell 6 (use cp65001 by default) > > PS C:¥> python3 -c "print('おはよう')" > ps.txt > > PowerShell standard I/O redirection is different from any shell I've ever > used. In this case, it runs Python with StandardOutput set to a handle for a > pipe instead of a handle for the file. It decodes Python's output using > whatever encoding is configured for input and re-encodes it with whatever > encoding is configured for output.
I'm sorry, I mixed my assumption. I checked `os.device_encoding()` in cmd, but forgot to check it on Power Shell. All I said about Power Shell was just my assumption and it was wrong. And thank you for clarifying. I confirmed writing UTF-8 to pipe cause mojibake, because Power Shell decodes it using cp932. ``` PS C:\Users\inada-n> python3 -Xutf8 -c "import os,sys; print(os.device_encoding(1), sys.stdout.encoding, file=sys.stderr); print('こんにちは')" >x None utf-8 PS C:\Users\inada-n> type x ``` Hmm, how can I teach to Power Shell about python3 is using UTF-8 for stdout? It seems cmd.exe with chcp 65001 and PYTHONUTF8=1 is better than PowerShell when I want to use UTF-8 on Windows. Anyway, nothing is wrong about python. I just didn't understand PowerShell at all. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue37275> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com