1

I have a problem with powershell: in Powershell I cannot enter language specific characters (diacritic characters). It has wrong encoding, so I started digging in that direction, finally coming up with chagning codepage. And here's the deal: ISE has codepage 1250 and I can easily enter diacritics, while in Powershell code page is 852 and chcp 1250 or chcp 65001 doesn't help.

Please see below picture presenting different outputs of [Console]::OutputEncoding and diacritics entered in ISE.

enter image description here

Michał Turczyn
  • 32,028
  • 14
  • 47
  • 69
  • I hope the [linked answer](https://stackoverflow.com/a/49481797/45375) explains it all, but the short of it is that running `chcp` from _inside_ PowerShell is ineffective. Use `$OutputEncoding = [console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding` or `$OutputEncoding = [console]::InputEncoding = [console]::OutputEncoding = [Text.Encoding]::GetEncoding((Get-Culture).TextInfo.ANSICodePage)` – mklement0 Apr 04 '20 at 12:36
  • @mklement0 Unfortunately, this doesn't work. Well, it worked in that way, that I successfully change code page for input and output encoding. But `chcp` still shows 852 and I can't enter any diacritics. – Michał Turczyn Apr 04 '20 at 13:20
  • If I run the commands from the previous comment and then `chcp`, I get `65001` and `1252` (my system's active ANSI code page), respectively. This is on Windows PowerShell v5.1.18362.628 on Microsoft Windows 10 Pro (64-bit; Version 1909, OS Build: 18363.720). Can we narrow down why your system behaves differently? – mklement0 Apr 04 '20 at 13:44
  • Also, on said system I can enter Polish characters even _without_ having switched the code page. – mklement0 Apr 04 '20 at 14:16
  • @mklement0 I have exactly the same widnows version and build. PS as well – Michał Turczyn Apr 04 '20 at 14:45
  • @mklement0 Is there possibility that I somehow turned it off? But why is it working in ISE? – Michał Turczyn Apr 04 '20 at 14:47
  • I have no explanation for your symptoms, I'm afraid, but I've reopened the question in case someone else does. The ISE uses its own emulation of a console window, which defaults to the ANSI code page, whereas regular console windows default to the OEM code page. Can you not even _paste_ Polish characters? Have you tried different fonts? – mklement0 Apr 04 '20 at 14:49
  • @mklement0 Yes, I can paste for example `kość` and it echoes it correctly. It's like it doesn't like "Alt+letter" combination (used to enter diacritics). – Michał Turczyn Apr 04 '20 at 14:51
  • Anything unusual in your $profile? – js2010 Apr 04 '20 at 14:54
  • @js2010 It shows just a path to some Powershell script, which even didn't exist (I created it couple of hours ago, to set encoding at the PS start, which didn't work). – Michał Turczyn Apr 04 '20 at 14:56
  • Try unloading the `PSReadLine` module before typing the chars.: `Remove-Module PSReadLine`. – mklement0 Apr 06 '20 at 13:55

0 Answers0