I'm making a forms application with powershell. I'm having issues getting the characters "æ", "ø", "å" to be displayed correctly in a label. See the screengrab below for how they appear. There seems to be some type of encoding issue and since Powershell holds the characters as utf-16 in memory, I'm guessing the issue is with the System.Windows.Forms.Label
I'm using.
Add-Type -AssemblyName System.Windows.Forms
$Form = New-Object system.Windows.Forms.Form
$Form.Width = 800
$Form.Height = 500
$Form.BackColor = "#dff3ee" #"#00554b"
$Form.AutoSize = $false
$Form.StartPosition = "CenterScreen"
$Info= New-Object System.Windows.Forms.Label
$Info.Width = 250
$Info.Height = 70
$Info.AutoSize = $false
$Info.Location = New-Object System.Drawing.Point(20,20)
$Info.Font = "Arial Unicode MS, 9"
$Info.Text = "Why is this æøå displayed wrong"
$Form.Controls.AddRange(@($Info))
$Form.ShowDialog()
$PSVersionTable
Name Value
---- -----
PSVersion 5.1.18362.145
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.18362.145
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
I'm not able to fix the issue. But I'm packing this in a .exe with PS2EXE and then the characters are displayed correctly. Since it is correct in prod I'm not gonna bother anymore with this.