Vscode: how to auto detect , auto encoding ?

Created on 1 Apr 2016  ·  41Comments  ·  Source: microsoft/vscode

hi ,

3

not working

{
    "files.encoding": "shiftjis",
    "files.encoding": "eucjp",
    "files.encoding": "big5hkscs",
    "files.encoding": "Big5",
    "files.encoding": "GB18030",
    "files.encoding": "GB2312",
    "files.encoding": "utf8",
    "files.encoding": "GBK"
}
needs more info

Most helpful comment

@hackjackyer 我们需要是VSCode自动检测文件编码并设置正确的编码,而不是只套用一个预设的编码


What we need is the ability that VSCode can detect the encoding of the file and set the correct encoding automatically rather than a default encoding to apply to all files.

All 41 comments

@xianghongai so in what encoding is this file?

hi,@bpasero ,
1
ANSI , Chinese Simplified(GBK) .

@xianghongai can you attach it here?

兄弟,别指望了,我很久之前就提过,他们的回答是目前已经支持带DOM头的文件编码检测,不带DOM的不检测,我弄了个插件检测编码的,现在编码是检测成功了,但是切换编码卡住了,他喵的切换的API不开放,未来很长一段时间这个功能都不会有,不介意的话可以等等我的插件上线,由于接口限制,插件只能到 Change File Encoding那一步,顺带把检测的编码告诉你,手动切换一下

@iHuahua maybe as full file?

@bpasero batch file :)
文件命名操作.zip

@iHuahua 谢谢了,目前我是几个编辑器混着用的,可以解决一些问题,千万不要用sublime text编辑这种GBK编码格式的文件!我写批处理,几百行代码后,ST突然一个auto encoding 把我代码中文部分全乱码了!而且是撤销不了的乱码。

I do not see myself able to handle this issue, @egamma please advise.

@iHuahua @xianghongai the development team does not speak Chinese. Can you please find someone that can translate your comment to English?

thx, @bpasero , @egamma ,
iHuahua he said the vs code support dom document encoding detection, he said he is developing a plug-in to solve the problem is not dom document coding, such as .txt .bat .reg files. because of the vs code interface restrictions, at present can only be achieved "Change File Encoding" by manual switching, can't auto encoding.
some problems because windows code pages (ANSI) by locale select the encoding, such as chinese simplified gbk, korean euc-kr, japanese cp932 and so on.
maybe these questions no solution.

fyi @bpasero

hi, when open a Lua file which's encoding is GBK and without BOM header, the VS Code can not aoto dectect the encoding. I need to switch utf8 to GBK by hand every time i open a new such file, It's annoying. I've install the gbktoutf8 extension to solve it (ext install gbktoutf8). But I hope the VS Code have some configuration to do it better. The VIM editor can config the dectect encodings order, which is a convention solution to this problem. @egamma

I have many projects, some of them are GBK encoded, other are UTF-8 encoded, so what can I do for setting different encoding for each project. appreciate for any help @egamma

any updates for this issues?

please fix it

any update of this issue?

Same here, always open a file at "UTF-8", but i need some files at "Western Windows 1252"

I am also having this kind of problem. Orignal file is ANSI with german umlauts and code converts it to UTF-8, then I am loosing the umauts.

Very very old problem.
We hope this issues can be resolved as soon as possible...

Yes, very old

Atenciosamente,
Maurício R. Duarte.

2016-09-06 10:14 GMT-03:00 White99 [email protected]:

Very very old problem.
We hope this issues can be resolved as soon as possible...


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/Microsoft/vscode/issues/4846#issuecomment-244945697,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABE4_aK7SW_Qo3YM7baB83EJRj9qzQqiks5qnWdCgaJpZM4H9aUH
.

It's disgusting when I find all the notes have been garbled.It will take me hours to solve the issue.Why not release an extension to automatically switch the encoding format?

我的解决方式:
文件->首选项->用户设置->自动打开 settings.json。粘贴:

    // 读取和编写文件时将使用的默认字符集编码。
    "files.encoding": "GB2312"

GB大写。
done。

any updates for this issues?

It's a pity that vscode does not support auto encoding detect, but the Visual Studio does support that, and even the notepad2 could do that.

any updates?

any updates or new apis?

It's indeed annoying, usually web related files are utf-8 encoding, windows platform files are local encoding, so "files.encoding" setting is not helping at all, you still need to manually set half files each time.

any updates?

any updates?

Any supports or updates?

Any updates?

C:\Users\USERNAME\AppData\Roaming\Code\User\settings.json文件内容。即可
{ "files.encoding": "GB2312" }

@hackjackyer 我们需要是VSCode自动检测文件编码并设置正确的编码,而不是只套用一个预设的编码


What we need is the ability that VSCode can detect the encoding of the file and set the correct encoding automatically rather than a default encoding to apply to all files.

为什么不写个插件来对所有(或者大部分)的编码来进行判断呢?

Why not write a plugin for judge the encoding?
if encoding = 'utf-8'
elif ....

Any updates?

Update!

Pull request: #21416

为什么我明明是UTF8,但是自动转换为GB2312,导致显示乱码

setting

"files.autoGuessEncoding": true,

setting

"files.autoGuessEncoding": true,

@a4027971 Is this option real ? Exists ?

Is this option real ? Exists ?
@mauriciord

VSCode verision : 1.14.1
OS : windows 7 x64

This option really exists

official documentation

hot key:ctrl+Comma, then change " "files.autoGuessEncoding": false " to " "files.autoGuessEncoding": true ".

Was this page helpful?
0 / 5 - 0 ratings

Related issues

trstringer picture trstringer  ·  3Comments

sirius1024 picture sirius1024  ·  3Comments

omidgolparvar picture omidgolparvar  ·  3Comments

lukehoban picture lukehoban  ·  3Comments

curtw picture curtw  ·  3Comments