Powershell(也是 cmd)无法识别特殊字符“±、Ç”等

Powershell(cmd too) doesn't recognize special characters "ą, ę" etc

Powershell 无法识别特殊字符,例如:“ą”、“ę”、“ć”等。 使用类似的东西时:

PS C:\> Get-Content test.txt | findstr /c:something

??? something 

PS C:\> Get-Content test.txt | findstr /c:ę => nil

你可能猜到任何特殊字符都会显示问号。

我使用 运行 ruby 脚本,当我 运行 $stdin.gets.chomp 带有特殊字符的输入显示为空时,脚本中的每个字符都按预期工作盒子。

input = $stdin.gets.chomp

puts input => ▯

并且它显示空方框(对于早期版本的 Powershell,它使用问号代替)

我正在尝试 https://blogs.msdn.microsoft.com/powershell/2006/12/11/outputencoding-to-the-rescue/,但这对我不起作用。

如有任何有用的建议,我将不胜感激。

编辑:将 chcp 更改为 1250 而不是 $OutputEncoding =[Console]::OutputEncoding 在 findstr /c:something 时显示“±something”,但在 findstr /c:ə 时不显示任何内容。在 ruby.

中更改 chcp 会产生兼容性问题

Edit2:我的其他研究都在那里

谢谢

尝试使用纯 powershell,不要与可执行文件混合(-match 而不是 findstr):

Get-Content C:\temp\encoding.txt -Encoding Unicode| ? {$_ -match "ę"}

在文件中查找匹配项(当 txt 保存为 Unicode 时):

Get-Content C:\temp\encoding.txt -Encoding Unicode

ę 
asd
ęę
#ääöpl

我的文件包含 4 行,如上所示

Get-Content C:\temp\encoding.txt -Encoding Unicode| ? {$_ -match "ę"}

ę 
ęę

德语字符 - “元音变音”,如 Ä,Ö 和 UTF8

Power Shell ISE/Terminal

$file='c:/test.txt'
# content of $file: Verknüpfung mit einem Master..

get-content $file -encoding utf8

预期/实际产出

链接到大师..