I'm on Windows 10 with Powershell 5.1
printargs.py
is:
#! /usr/bin/python3
import sys
for arg in sys.argv:
print(arg)
Case 1
I have a Windows batch file runme.bat
:
chcp 65001
py printargs.py ä
Note: py.exe
is the Python launcher for Windows
This is working: I invoke the batch file in a Powershell terminal and I get output
printargs.py
ä
Case 2
Now I want powershell script runme.ps1
doing exactly the same thing:
# What code must go here?
& py printargs.py ä
This is NOT working: Because of some encoding problem I get
printargs.py
ä
I' am aware of this question.
I tried without success:
$OutputEncoding = [console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding