Skip to content

Invoke-WebRequest should support -Encoding parameter for default character set #19226

@rhubarb-geek-nz

Description

@rhubarb-geek-nz

Summary of the new feature / enhancement

This is a follow up to #19156

Other cmdlets use an "-Encoding" parameter, eg Get-Content. It would be nice if this was used for the default encoding character set when the character set is not present in the ContentType and the body is some form of string rather than binary. This would be better than treating certain MIME types as somehow special.

Proposed technical implementation details (optional)

The Invoke-WebRequest refers to a default character set but it is not clear how this is determined, and the behaviour is different between 7.3.3 and powershell-7.4.0-preview.1

The concept is to use the "-Encoding" parameter to specify the default character set if it is not present in the MIME type.

An example is "application/json" is technically a binary encoding so should not have the charset in the ContentType.

It would be better to use an explicit "-Encoding" parameter than maintain a list of special MIME types that need particular character set encodings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugWG-Cmdletsgeneral cmdlet issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions