You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Invoke-WebRequest's .ToString() assumes content is ASCII #27154
If the content is non-ascii this causes characters to be converted to '???'
Expected behavior
Non-ascii characters in the response body remain unchanged
Actual behavior
Non-ascii characters become '???'
Error details
Environment data
Name Value
---------
PSVersion 7.6.0
PSEdition Core
GitCommitId 7.6.0
OS Microsoft Windows 10.0.22631
Platform Win32NT
PSCompatibleVersions {1.0,2.0,3.0,4.0…}
PSRemotingProtocolVersion 2.4
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
toString() is a fuzzy "preview" function, not the recommended way to process production data. The challenge is: with text and non-BOM-encoding, there is no way other than heuristically to determine the original encoding.
So toString() must pick one encoding in random best effort. Or is there a reliable HTTP header information that reveals the encoding? I am not much of a HTTP expert I admit.
@PowerShell/wg-powershell-cmdlets discussed this. We believe in most cases the encoding should be available as part of the header. If not, it would make sense to default to utf-8 instead of ASCII.
Activity
TobiasPSP commentedon May 6, 2026
toString() is a fuzzy "preview" function, not the recommended way to process production data. The challenge is: with text and non-BOM-encoding, there is no way other than heuristically to determine the original encoding.
So toString() must pick one encoding in random best effort. Or is there a reliable HTTP header information that reveals the encoding? I am not much of a HTTP expert I admit.
SteveL-MSFT commentedon Jul 15, 2026
@PowerShell/wg-powershell-cmdlets discussed this. We believe in most cases the encoding should be available as part of the header. If not, it would make sense to default to utf-8 instead of ASCII.