Daniel
April 4, 2022, 5:06pm
1
Product: PowerShell Universal
Version: 2.9.2
I have a Test TXT File with content:
123
zzz
yxy
äöü
The Code:
’
$ImageData = [IO.File]::ReadAllBytes(“c:\psu\test.txt”)
New-PSUApiResponse -ContentType ‘image/jpg’ -Data $ImageData
’
The Output:
in Powershell 5 and 7:
123
zzz
yxy
äöü
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?
1 Like
Daniel
April 5, 2022, 2:26pm
3
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 ?
Daniel
April 5, 2022, 6:32pm
5
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.
Daniel
April 5, 2022, 7:36pm
6
To Many Encodings…
Get the Invoke-RestMethod output and decode with 28591.
$encoding2 = [System.Text.Encoding]::GetEncoding(28591)
[IO.File]::WriteAllBytes(“c:\psu\TestfileRest.txt”, $encoding2.GetBytes($OutputREST))
and works with other files too.