Product: PowerShell Universal
I have a Test TXT File with content:
$ImageData = [IO.File]::ReadAllBytes(“c:\psu\test.txt”)
New-PSUApiResponse -ContentType ‘image/jpg’ -Data $ImageData
in Powershell 5 and 7:
I have german os language and etc.
First i try the png/jpg file example but with no success.
How do i download files on a non english installation?
After hours with try and search…
[text.encoding]::utf8.getstring([text.encoding]::default.GetBytes(($OutputRestAPI | convertto-json))) | ConvertFrom-Json
What is the encoding in the text file?
I guess not UTF8 ?
The file is UTF8 … but the encoding from Default to UTF8 works with same chars but not for all chars…
it is close…but there are chars like ß with errors.
To Many Encodings…
Get the Invoke-RestMethod output and decode with 28591.
$encoding2 = [System.Text.Encoding]::GetEncoding(28591)
and works with other files too.