I have a weird thing going on in my PowerShell script using Subversion commands. Following is an PowerShell example script:
$svnOutput = svn status
Write-Host "Output when saved in a variable"
$svnOutput
Write-Host "Direct Output"
svn status
If I run this script (within the PowerShell console), I get two different outputs, if one of the files have non-ASCII-characters in the name (in my examples umlauts like üöä). This is the output:
Output when saved in a variable
? Test_���.txt
Direct Output
? Test_äöü.txt
I am working on a Windows Server 2022 with a VisualSVNServer version 5.4.1. I already tested following ideas:
chcp 65001
$svnOutput = svn status
$svnOutput
$OutputEncoding = [System.Text.Encoding]::UTF8
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
$svnOutput = svn status
$svnOutput
$svnOutput = & svn status | Out-String -Stream
$svnOutput
svn status > svn_status.txt
$svnOutput = Get-Content -Path "svn_status.txt" -Encoding UTF8
$svnOutput
$svnOutput = & svn status | Out-String -Stream
$svnOutput
But all of them give the same error.
PS: this also happens with other commands like
$svnOutput = svn add . --force
$svnOutput
which results in:
A Test_���.txt
Typing svn add . --force in a PowerShell instance, or even i a script works without any issues.
$OutputEncoding = [Console]::InputEncoding = [Console]::OutputEncoding = New-Object System.Text.UTF8Encoding[Console]::OutputEncodingdoesn't match the actual output encoding: normally, direct-to-console output renders fine, but capturing in a variable reveals an encoding mismatch. Also, what do you mean by "in the normal powershell"?$svnOutput = svn statusand afterwards output via typing$svnOutputin the powershell instace, I get the same sympton as via a script.