curl -s "https://docs.microsoft.com/zh-cn/powershell/scripting/overview?view=powershell-7"|`
Select-String "^.+ - Powershell"|`
%{$_.matches.Value}
<title>
PowerShell 脚本 - PowerShell | Microsoft Docs
</title>
In powershell 6.2.3 it works as expected
<title>
PowerShell é‘´æ°æ¹° - PowerShell | Microsoft Docs
</title>
Name Value
---- -----
PSVersion 7.0.0
PSEdition Core
GitCommitId 7.0.0
OS Microsoft Windows 10.0.18363
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
@SteveL-MSFT Cpuld you please comment the issue?
@iSazonov are there any settings in my environment wrong? Btw, I run chcp 65001 in the profile
@onriv, chcp 65001 from inside PowerShell isn't effective, because .NET caches the value of [Console]::OutputEncoding, which is what matters with respect to how PowerShell decodes stdout output from external programs.
You must set the latter directly:
[Console]::OutputEncoding = [System.Text.UTF8Encoding]::new($false)
See #7233 for details, which requests that UTF-8 be made the default (consistently; $OutputEncoding has fortunately already been switched to UTF-8).
@mklement0 The issue is on Windows where curl is cmdlet alias.
@iSazonov, no, it is only an alias in _Windows PowerShell_; the alias was removed in PowerShell Core.
P.S., the only reason it worked in 6.x was a _bug_ that caused [Console]::OutputEncoding to be ignored and UTF-8 to always be used - see #10789
@mklement0 I didnt know that chcp not working in powershell and didnt know there is a bug in PS6 too. Now I tried setting [Console]::OutputEncoding = [System.Text.UTF8Encoding]::new($false) in
PS7 and it works now. Thank you very much. I will check the docs you mentioned later.
I think can track this in #10789
Since My problem solved and there are enough informations to be referred. I closed the issue. Thank you very much
Most helpful comment
@iSazonov, no, it is only an alias in _Windows PowerShell_; the alias was removed in PowerShell Core.