- I create a file, execute the following command:
:set fileencoding
- result is :
fileencoding=cp936
- I edit and then close the file. I reopen the file and execute the following command:
:set fileencoding
- result is :
fileencoding=utf-8
The contents of .vimrc are:
...
set fencs=ucs-bom,utf-8,gbk,gb18030,utf-16,big5
set fenc=cp936
set encoding=utf-8
Also, I used a remote connection in vscode. Why does the value of fileencoding change? What is the reason for this ? How to solve this problem ? thanks!
Here are the results of my attempts:
- When the content contains only English, content is as follows, I save and reopen it. And then i execute the command: set fileencoding, the result is
fileencoding=utf-8
。also, I executefile test1.c
,the result istest1.c: ASCII text
.
//file: test1.c
abc
- When the content contains Chinese: content is as follows, I save and reopen it. And then i execute the command: set fileencoding, the result is
fileencoding=cp936
。also, I executefile test2.c
,the result istest2.c: ISO-8859 text
.
//file:test2.c
你好abc
.vimrc
content is :
...
set fencs=ucs-bom,utf-8,gbk,gb18030,utf-16,big5
set fenc=cp936
set encoding=utf-8
My question is why fileencoding is utf-8 and not cp936 when the content is in English only?