-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Fix #36951: Add the "file.encoding_candidate" attribute for selecting encoding to open file. #117053
Conversation
Thanks for the PR, a little bit on the expectation: I will probably not have time to review this until we get to our yearly issue grooming iteration in October. |
This seems to be building around the |
Besides, we cannot really decode the entire document at once just to check on error for performance/memory reasons and we cannot decode a chunk because we don't really know the byte size... |
Also, |
Thanks @bpasero to give me some comments! Yes, I did not consider such details you mentioned ( To make it work in browsers, maybe I will try to find other text decoder instead of TextDecoder. But is there a way to check the encoding of a file without decoding all its content? I thought it is necessary to get the accurate result. |
TLDR
I try to solve #36951 in the way like "set fileencodings= xxx,xxx" in vim.
How to use :
If we want to try to open a file in the order of "utf-8", "big5", "...(some codepages you want)".
In the setting.json, just add -
Then the editor will try to open file with "utf-8", if it failed, try "big5", and so on.
Note :
I use "TextDecoder" to check if the file can be opened.
Thus please check that the encoding you want to use exists in "TextDecoder" before use.
Priority:
auto detected encoding < file.encoding_candidate
For #36951.