Quantcast
Channel: Active questions tagged utf-8 - Stack Overflow
Viewing all articles
Browse latest Browse all 1060

How to capture the output string of a UTF-8 program using PowerShell?

$
0
0

The program inv.exe returns some console data based on parameters. It seems like a JSON/dictionary, but it's in text format (printed output). It works when I simply call it without trying to capture the output.

.\inv.exe getter segments{28: 'Renda Fixa', 29: 'Renda Variável', ...

However, if I try to capture it, it doesn't work:

$segmentsjson = .\inv.exe getter segments$segmentsjson{28: 'Renda Fixa', 29: 'Renda Vari�vel'....$segmentsjson = .\inv.exe getter segments | ConvertFrom-Json$segmentsjson{"28": "Renda Fixa", "29": "Renda Vari├ível"...

What I tried:

1. chcp 650012. $OutputEncoding = [System.Text.Encoding]::UTF83. [Console]::OutputEncoding = [System.Text.Encoding]::UTF84. $OutputEncoding = [Console]::InputEncoding = [Console]::OutputEncoding = New-Object System.Text.UTF8Encoding5. .\inv.exe getter segments > test.txt$segmentsjson = Get-Content "test.txt" -Encoding UTF86. .\inv.exe getter segments | Out-File -FilePath "output_temp.txt" -Encoding UTF-87. cmd /c inv.exe getter segments > test.txt

Viewing all articles
Browse latest Browse all 1060

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>