On Sat, Nov 12, 2022 at 11:53 AM Inada Naoki <songofaca...@gmail.com> wrote: > > On Sat, Nov 12, 2022 at 10:21 AM 12Jessicasmith34 > <12jessicasmit...@gmail.com> wrote: > > > > > > Two questions: any idea why this would be happening in this situation? > > AFAIK, stdout *is* a console when these images are running the python > > process. Second - is there a way I can check the locale and code page > > values that you mentioned? I assume I could call GetACP using ctypes, but > > maybe there is a simpler way? > > > > Maybe, python doesn't write to console in this case. > > python -(pipe)-> PowerShell -> Console > > In this case, python uses ACP for writing to pipe. > And PowerShell uses OutputEncoding for reading from pipe. > > If you want to use UTF-8 on PowerShell in Windows, > > * Set PYTHONUTF8=1 (Python uses UTF-8 for writing into pipe). > * Set `$OutputEncoding = > [System.Text.Encoding]::GetEncoding('utf-8')` in PowerShell profile. >
I forgot [Console]::OutputEncoding. This is what PowerShell uses when reading from pipe. So PowerShell profile should be: $OutputEncoding = [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 -- Inada Naoki <songofaca...@gmail.com> -- https://mail.python.org/mailman/listinfo/python-list