Vscode: Automatically detect encoding of the file opened

Created on 16 Apr 2016  路  14Comments  路  Source: microsoft/vscode

Steps to Reproduce:

  1. Use Notepad to save the batch under windows, So Character set is GBK.
  2. open xxx.bat
  3. All chinese text is garbled
feature-request file-explorer

Most helpful comment

Why is someone trying to close this issue??
To be honest, auto encoding detection is one of the basic features of a modern editor. VS Code team need to face this issue rather than avoiding it.
Seriously.

All 14 comments

Same here. Mac OSX El Captain
VSCode v.1.3.1

When i open a file "Windows 1252", it changes automatically to UTF-8, then i need to reopen as "Windows 1252" and save. If i close the VSCode and open, the files will be "UTF-8"

+1

How about adding setEncoding API to VSCode and creating auto detect and changing extension?

Curren status: you always can set a workspace encoding to be used for all files of an opened folder. You can also configure this globally for any files being opened (files.encoding).

Things that would help a lot already is to persist the encoding for particular files when changed from the status bar. This is tracked in https://github.com/Microsoft/vscode/issues/10444

I am using Chinese Simplified Win10 now.
Some of my old cpp and cs files(not many) are ANSI(GBK)-encoding which were created by old version of Visual Studio.
VS can open ANSI files correctly and I can search ANSI(GBK) string through files. With VSCode I have to open file and choose the correct encoding to search.

Notepad++ are more powerful dealing with encodings, it can detect many encodings and open correctly. So I don't need to choose the encoding manually and I can search a string from files mixed with GBK-encoding and BIG5-encoding without opening them, even if the hex-codes of the string are different in GBK and BIG5.

It would be good if vscode could detect encodings, at least ANSI encoding.

Great to see plan/progress on this issue. I agree that auto detecting encoding would be a great help for large projects which may has various encoding for environments difference or historical reasons across thousands of files. Really need this feature +1.

I expect this issue to appear in the iteration plan.

Why is someone trying to close this issue??
To be honest, auto encoding detection is one of the basic features of a modern editor. VS Code team need to face this issue rather than avoiding it.
Seriously.

Landed via the new files.autoGuessEncoding setting leveraging the power of jschardet.

+1

File encoding is most important issue for NON-ENGLISH PEOPLE!!
You English people don't know how we non-english people bored for changing encoding when opening file each time...

If someone wants to verify this, the feature landed in insiders (tomorrows build): https://github.com/Microsoft/vscode/issues/23322

bpasero, the issue doesn't appear to be resolved in the new build. I replied to that thread with a demo of the persistent bug.

@duanehutchins and I commented. in general I would suggest to report issues into new issues and not closed ones to keep the discussion separate.

Was this page helpful?
0 / 5 - 0 ratings