Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to associate a file encoding per file path #23570

Closed
duanehutchins opened this issue Mar 29, 2017 · 3 comments
Closed

Allow to associate a file encoding per file path #23570

duanehutchins opened this issue Mar 29, 2017 · 3 comments
Labels
feature-request Request for new features or functionality file-encoding File encoding type issues *out-of-scope Posted issue is not in scope of VS Code

Comments

@duanehutchins
Copy link

  • VSCode Version: 1.11.0-insider
  • OS Version: Windows 8.1-Pro

Here is a gif of the bug in action:
vscode-fileencode
TXT Files refrenced: iso-8859-1.txt and shift-jis.txt

Steps to Reproduce:

  1. Open the attached text files with the corresponding encoding.
  2. Verify the characters display properly and the encoding is correct in the bottom-right corner of VS code.
  3. (Re)Save the files using the same encoding.
  4. Close the files.
  5. Open the files normally (Without specifying the encoding).
  6. The encoding used to open the files is not the same encoding used to save the files. The characters do not display properly.
  7. Enabling files.autoGuessEncoding does not resolve the issue, but it does change which encoding is guessed.

Note that if I run file -bi iso-8859-1.txt from Git Bash, I can see the correct encoding is returned.

@bpasero
Copy link
Member

bpasero commented Mar 29, 2017

@duanehutchins this is specifically why we introduced the files.autoGuessEncoding setting. If you are not having this enabled by default, we use the encoding configured in files.encoding for opening and saving files. The only exceptions are UTF-8 with BOM or UTF-16 with BOM.

As for your 2 cases I filed aadsm/jschardet#30 and aadsm/jschardet#31

I leave this open to allow to store an encoding for a specific file path.

@bpasero bpasero changed the title Files use the wrong encoding when opened Allow to associate a file encoding per file path Mar 29, 2017
@bpasero bpasero added file-explorer Explorer widget issues feature-request Request for new features or functionality workbench labels Mar 29, 2017
@bpasero bpasero removed their assignment Mar 29, 2017
@bpasero bpasero removed the workbench label Nov 16, 2017
@isidorn isidorn added file-encoding File encoding type issues and removed file-explorer Explorer widget issues labels Nov 17, 2017
@bpasero bpasero removed their assignment Nov 17, 2017
@vscodebot vscodebot bot added the *out-of-scope Posted issue is not in scope of VS Code label Oct 8, 2019
@vscodebot
Copy link

vscodebot bot commented Oct 8, 2019

This issue is being closed to keep the number of issues in our inbox on a manageable level, we are closing issues that are not going to be addressed in the foreseeable future: We look at the number of votes the issue has received and the number of duplicate issues filed. More details here. If you disagree and feel that this issue is crucial: We are happy to listen and to reconsider.

If you wonder what we are up to, please see our roadmap and issue reporting guidelines.

Thanks for your understanding and happy coding!

@GitMensch
Copy link
Contributor

GitMensch commented Apr 28, 2020

As #30857 was closed as a duplicate of (partially) this and there's a real relevance to be able to set the encoding via file-path (although it likely will work for many to set per workspace, but not all people use the workspace approach and you are not unlikely to have files in the same workspace that use a different encoding): "please reconsider and opening this issue".

I guess the biggest point is how to handle conflicting situations (settings in a path vs. file specific extensions). I suggest to give the path specific setting the higher priority but the option to limit it:

        "files.encoding": "utf8",
        "file.encodingPaths": [
           {
              "pattern": "**/folderA/**",
              "encoding": "windows1251"
           },
           {
              "pattern": "**/folderA/subFolder/**",
              "encoding": "*"
           }
        ]

This way all files in "folderA" would get the windows1251 encoding but the files in "olderA/subFolder" would not have the setting applied (and in this case because of the global setting the utf8 encoding).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality file-encoding File encoding type issues *out-of-scope Posted issue is not in scope of VS Code
Projects
None yet
Development

No branches or pull requests

4 participants