0

It is possible to show special german characters like “ä ü ö” in a powershell form? Because right now the characters are replaced with some weird characters. Right now i have something like

$form1 = New-Object System.Windows.Forms.Form
$Label1 = New-Object System.Windows.Forms.label
$Label1.Text = "ä ü ö"
$form1.Controls.Add($Label1)

And the output is something like in this picture : weird charachters . I tried to search on the internet and I know that the problem is from the encoding, but I don't know how to integrate this in my script and didn't find the correct script line which will solve the problem.

L.E: I need this piece of code to work in ps1 file ..

ARB
  • 5
  • 3
  • Does this answer your question? [UTF8 Script in PowerShell outputs incorrect characters](https://stackoverflow.com/questions/14482253/utf8-script-in-powershell-outputs-incorrect-characters) – JosefZ Feb 23 '21 at 14:26
  • @JosefZ This answer to my question partially. I think I know the problem and how to fix it but I don't know the command to set UTF8withBOM .. – ARB Feb 23 '21 at 14:51

1 Answers1

0

Not an answer, but too much text for a comment...

I've added some missing bits from your sample, and the following works fine for me here:

Add-Type -AssemblyName "System.Windows.Forms"

$form1 = New-Object System.Windows.Forms.Form
$Label1 = New-Object System.Windows.Forms.label
$Label1.Text = "ä ü ö"
$form1.Controls.Add($Label1)

$form1.ShowDialog();

enter image description here

mclayton
  • 8,025
  • 2
  • 21
  • 26
  • This is working if you type this in the powershell console, but is not working if you put them into ps1 script and run with the comand powershell -file filename.ps1 ... – ARB Feb 23 '21 at 14:36
  • 1
    It’s probably the encoding of your *.ps1 file then - try saving it as UTF8 in your text editor and see if that fixes it. – mclayton Feb 23 '21 at 16:52
  • Oh, i get it now. Thank you! – ARB Feb 23 '21 at 18:31