Skip to content

Unrecognized encoding #12861

Closed
Closed

Description

@he852100

Steps to reproduce

$a=@'
ascii.txt
unicode.txt
utf32.txt
utf8.txt
utf8bom.txt
'@ -split "\s"
$url='https://raw.githubusercontent.com/he852100/111/master/Test/'
$a|%{"$((irm $url$_) -split '\s' -match '.')`t$_"}

Expected behavior

123456你好    ascii.txt
123456你好    unicode.txt
123456你好    utf32.txt
123456你好    utf8.txt
123456你好    utf8bom.txt

Actual behavior

123456??        ascii.txt
��123456`O}Y    unicode.txt
��123456`O}Y    utf32.txt
123456你好      utf8.txt
(bom)123456你好     utf8bom.txt

Environment data

PSVersion                      7.1.0-daily.20200530
PSEdition                      Core
GitCommitId                    7.1.0-daily.20200530
OS                             Linux 4.9.112-perf #1 SMP PREEMPT Mon…
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Detecting charset=xxx has no purpose

Assuming it is a ps1, it will have serious compatibility issues

Activity

  1. added
    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a
    on Jun 1, 2020
  2. mklement0 commented on Jun 1, 2020

    @mklement0
    Contributor

    To clarify the problem: the responses all indicate UTF-8 via the charset attribute in the Content-Type header field, but the actual payloads (file contents) are differently encoded, but indicate their specific encoding with a BOM.

    Currently, PowerShell only considers the charset-specified encoding (in whose absence it currently assumes ISO-88591-), and ignores the BOM (even reading it as data).

    Arguably, a BOM in the payload, if present, should take precedence over the charset attribute.
    See #11547 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-DuplicateThe issue is a duplicate.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions