Skip to content

Support utf-8 encoding guessing  #84495

Closed
sunbohong/vscode
#1

Description

utf-8(['ascii', 'utf-8', 'utf-16', 'utf-32']) encoding guessing is disabled by this line. Ignore encodings that cannot guess correctly
But this link didn't mention it.
And in my test,the follow text will be guessing as utf-8 correctly(result='utf-8').
image

jschardet result:

image

In the other hand,with the follow setting, it will be detect as GBK

image

image

Activity

  1. vscodebot commented on Nov 11, 2019

    @vscodebot

    (Experimental duplicate detection)
    Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

  2. sunbohong commented on Nov 12, 2019

    @sunbohong
    ContributorAuthor
  3. sunbohong commented on Nov 12, 2019

    @sunbohong
    ContributorAuthor
  4. bpasero commented on Nov 12, 2019

    @bpasero
    Contributor

    I like this change because it makes jschardet more deterministic by giving it full control over the detection. I still think more work is needed to increase the confidence of the detection, but that can continue in other issues.

  5. bpasero commented on Nov 12, 2019

    @bpasero
    Contributor

    酷酷的哀殿 (@sunbohong) I noticed a bad regression though that made me push ddfca30 to ignore the guessed encoding "ascii" for a simple reason:

    • user opens a text file with just ascii characters
    • we guess the encoding to be "ascii"
    • user types special characters (like german umlaut)
    • user saves and closes the file
    • user reopens the file

    => the file is still guessed as "ascii" because it was not saved with a proper encoding

  6. added
    verification-needed
    on Nov 19, 2019
  7. bpasero commented on Nov 19, 2019

    @bpasero
    Contributor

    Verification:

    • configure "files.autoGuessEncoding": true
    • configure "files.encoding": "windows1252" (simply to a non-UTF8 encoding)
    • save a file with special characters contents (e.g. 私は和食が好きです。) as UTF-8
    • close all files
    • open it in VSCode

    => the encoding should be UTF-8 from the status bar.

  8. added
    verified
    verification-found
    and removed
    verified
    verification-found
    on Dec 3, 2019
  9. bpasero commented on Dec 5, 2019

    @bpasero
    Contributor

    Given scary issues such as #85821 I am putting UTF-16 and 32 back to the list of ignored encodings for guessing. Still, UTF-8 can be guessed.

  10. sunbohong commented on Dec 5, 2019

    @sunbohong
    ContributorAuthor

    Benjamin Pasero (@bpasero) From this issue #85821, we really need to replace jschardet with a new library

  11. locked and limited conversation to collaborators on Dec 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

feature-requestverification-neededverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions