Powershell - Embedded Script [Encoding Problem with Umlauts]

Resolved

Powershell - Embedded Script [Encoding Problem with Umlauts]

avatar

Hi there,

it seems that when running with powershell embedded scripts the file is getting saved in utf8 format.
This causes issues with for example often in germany used umlauts characters.

As example to reproduce:
forum image

whoami
Write-Host "This is a Test wit ae: ä and oe: ö or ss: ß"


Execute this script:
forum image
As you can see the umlauts are not correct:

This is a Test wit ae: ä and oe: ö or ss: ß


Checking the file in the TMP Directory we see that it is saved in UTF8:
forum image
If I execute this in a separate powershell session i have the same behaviour, so it's not directly related to RemoteDesktopManager - its a Powershell Problem.

If I convert the file with notepad++ to utf-8 with bom and execute it with powershell the output is as wanted.
forum imageforum image

So my question is: Can we specify the default file encoding for the embedded scripts or is it otherwise possible to change from utf-8 to utf 8 with bom? I've not found sth. in the Settings so far.

Kind regards,
Constantin

All Comments (7)

avatar

A temporary workaround is to store the powershell script not within RDM directly and link it in the filesystem. But thats not really desired because then we have a dependency more, to reach a smb share :-)

avatar

Hello,

Let me check if it's possible to add a default file encoding setting for embedded scripts in the PowerShell entry type with the engineering team and will get back to you.

Thank you for your patience.

Best regards,

Érica Poirier

avatar

Hello,

A ticket has been sent to our engineering department about this behaviour to find a solution to fix it. Once any information will available, we will update this thread.

Thank you for your patience.

Best regards,

Érica Poirier

avatar

Hi Erica,

thanks for the update :-)

Kind regards,
Constantin

avatar

Hello,

is there any update regarding this issue?
We just started using RDM (v. 2021.1.35 x64) and experiencing the same issues.

Best regards,
Christopher

avatar

Hello,

This is still under investigation. I will ask to bump up the priority of this ticket.

Thank you for your patience.

Best regards,

Érica Poirier

avatar

as a workaround you can implement a function which will use the coepage 1252 to output the specified string:

forum image

which will result in:

forum image

the function for easy copy/paste:

function Write-RDMHost ($String) {
    $bytes = [System.Text.Encoding]::GetEncoding(1252).GetBytes($String)
    return [System.Text.Encoding]::UTF8.GetString($bytes)
}


KR
G.