Is there any way to change the encoding of a file? For example UTF-8 to ISO 8859-1?
有没有办法改变文件的编码?例如UTF-8到ISO 8859-1?
Setting Example Sublime Text:
设置示例Sublime文本:
"default_encoding": "UTF-8"
2 个解决方案
#1
So here's how to do that:
所以这是如何做到这一点:
In the bottom bar of VSCode, you'll see the label
UTF-8
. Click it. A popup opens. ClickSave with encoding
. You can now pick a new encoding for that file.在VSCode的底部栏中,您将看到标签UTF-8。点击它。弹出窗口打开。单击使用编码保存。您现在可以为该文件选择新的编码。
Alternatively, you can change the setting globally in Workspace/User settings using the setting "files.encoding": "utf8"
. If using the graphical settings page in VSCode, simply search for encoding
. Do note however that this only applies to newly created files.
或者,您可以使用“files.encoding”:“utf8”设置在工作区/用户设置中全局更改设置。如果使用VSCode中的图形设置页面,只需搜索编码。但请注意,这仅适用于新创建的文件。
#2
Apart from the settings explained in the answer by @DarkNeuron:
除了@DarkNeuron在答案中解释的设置:
"files.encoding": "any encoding"
you can also specify settings for a specific language like so:
您还可以指定特定语言的设置,如下所示:
"[language id]": {
"files.encoding": "any encoding"
}
For example, I use this when I need to edit PowerShell files previously created with ISE (which are created in ANSI format):
例如,当我需要编辑以前用ISE创建的PowerShell文件(以ANSI格式创建)时,我会使用它:
"[powershell]": {
"files.encoding": "windows1252"
}
You can get a list of identifiers of well-known languages here.
您可以在此处获取众所周知语言的标识符列表。
#1
So here's how to do that:
所以这是如何做到这一点:
In the bottom bar of VSCode, you'll see the label
UTF-8
. Click it. A popup opens. ClickSave with encoding
. You can now pick a new encoding for that file.在VSCode的底部栏中,您将看到标签UTF-8。点击它。弹出窗口打开。单击使用编码保存。您现在可以为该文件选择新的编码。
Alternatively, you can change the setting globally in Workspace/User settings using the setting "files.encoding": "utf8"
. If using the graphical settings page in VSCode, simply search for encoding
. Do note however that this only applies to newly created files.
或者,您可以使用“files.encoding”:“utf8”设置在工作区/用户设置中全局更改设置。如果使用VSCode中的图形设置页面,只需搜索编码。但请注意,这仅适用于新创建的文件。
#2
Apart from the settings explained in the answer by @DarkNeuron:
除了@DarkNeuron在答案中解释的设置:
"files.encoding": "any encoding"
you can also specify settings for a specific language like so:
您还可以指定特定语言的设置,如下所示:
"[language id]": {
"files.encoding": "any encoding"
}
For example, I use this when I need to edit PowerShell files previously created with ISE (which are created in ANSI format):
例如,当我需要编辑以前用ISE创建的PowerShell文件(以ANSI格式创建)时,我会使用它:
"[powershell]": {
"files.encoding": "windows1252"
}
You can get a list of identifiers of well-known languages here.
您可以在此处获取众所周知语言的标识符列表。