Skip to content

Allow to configure a list of encodings to use when guessing #36951

Closed

Description

@JasonJunMa

The files.autoGuessEncoding=true doesn't work well in some circumstances.

I think that would be good if you guys add some features like files.forceEncoding="encode1:encode2,encode3:encode4".

So it can force 'encode1' to 'encode2'. That's a solution for wrong encoding detection I think.

Activity

  1. added
    feature-request
    on Oct 26, 2017
  2. fseasy commented on Oct 27, 2017

    @fseasy

    Yes, I'm totally agree because It is so weak for auto guess.
    Add a candidate may be better!
    For me, of may be Many Chinese Coder, only UTF-8 and GB18030 are most commonly meet, but auto-guess give me the Windows 1532??? I think is is easier to detect in users' encoding candidates.

  3. phobos2077 commented on Nov 15, 2017

    @phobos2077

    I agree. In my environment we have files in two encodings - UTF-8 and Windows1251 (most popular text file encoding in Russia), so I need to use encoding detection. However, it sometimes detects windows1251-encoded files as "maccyrillic" or "Windows1252" or some other encoding that I've never seen in my life :D
    Definitely need a setting like

    files.detectEncodings=["utf8","windows1251]

    So instead of just "true", you can specify which encodings you want it to detect from. As far as I know, encoding detection works based on probabilities (you can't 100% say which files is which encoding, so the software has to pick the most probable answer), so I think it is possible to implement - just filter out the list of possible encoding to those user selected.

  4. added
    file-encoding
    and removed
    file-explorer
    on Nov 17, 2017
  5. changed the title [-]Request feature in terms of encoding detection[/-] [+]Allow to configure a list of encodings to force[/+] on Sep 11, 2018
  6. 96 remaining items

  7. bpasero commented on Jun 5, 2024

    @bpasero
    Contributor

    Thanks to #208550, a new setting files.candidateGuessEncodings allows to specify which encodings are allowed to be guessed based on a string[] list. The option directly maps to the detectEncodings option in jschardet: https://github.com/aadsm/jschardet?tab=readme-ov-file#options

    This will be available in our insiders channel on Friday after we have released stable.

  8. peminator commented on Jun 5, 2024

    @peminator

    would love to try, please remind us in this thread to try after published or also after available to public.

  9. bpasero commented on Jun 6, 2024

    @bpasero
    Contributor

    This is now released in our insiders channel. You can give our preview releases a try from: https://code.visualstudio.com/insiders/

  10. formigoni commented on Jun 6, 2024

    @formigoni

    I have tried the implementation on Insiders versions!! It works like a charm!! Thanks Benjamin Pasero (@bpasero) thanks yutotnh (@yutotnh) thanks António Afonso (@aadsm) !!
    Here is how I have configured:

    {
        "files.candidateGuessEncodings": [
            "windows1252",
            "utf8"
        ],
        "files.autoGuessEncoding": true
    }
    
  11. added
    verification-needed
    on Jun 25, 2024
  12. alexr00 commented on Jun 25, 2024

    @alexr00
    Member

    Benjamin Pasero (@bpasero) do you want additional verification on this?

  13. bpasero commented on Jun 25, 2024

    @bpasero
    Contributor

    I think its fine given #36951 (comment)

  14. added
    verified
    and removed
    verification-needed
    on Jun 25, 2024
  15. formigoni commented on Jul 2, 2024

    @formigoni

    I don't know whether the right place to point out was here or in the pull request, but I have found a particular situation in which the encoding detection is not working properly.
    #208550 (comment)

  16. locked and limited conversation to collaborators on Jul 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

feature-requestfile-encodingverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions