Philippe Prados
Philippe Prados

Reputation: 491

Invoke Powershell with cmd and utf8 parameter

In a UTF-8 batch, I try to invoke:

powershell Start-Process cmd.exe -Verb runAs -Arg '/k chcp 65001 ^& echo été'

But the echo was :

Page de codes active : 65001
├®t├®

C:\WINDOWS\system32>

I would like "été" and not "├®t├®"

Upvotes: 1

Views: 785

Answers (1)

Theo
Theo

Reputation: 61028

You need to set the Console.OutputEncoding to UTF8 like this:

powershell.exe -Command {
    [Console]::OutputEncoding = [System.Text.Encoding]::Utf8
    Start-Process cmd.exe -Verb runAs -Arg '/k echo été'
}

Result:

été

Upvotes: 1

Related Questions