如何修复 VS Code 编码

问题描述 投票:0回答:1

我有很多包含阿拉伯字符的文件。当我在任何编辑器上打开它时,它都无法正确显示。 我通过Windows设置解决了这个问题,然后我尝试用bloc note打开它,它工作正常。

由于 Vscode 更适合编辑,我尝试打开那里的文件,但阿拉伯字符无法正确显示。

在右下角,我按 ISO 8859-2 > 用编码重新打开 > 阿拉伯语(Windows 1256),问题就解决了。

我尝试使用编码保存,但关闭并打开同一个文件,显然恢复了默认设置。

在 VScode 设置中,我这样做了:

"files.autoGuessEncoding":true
另外,我将用户和工作区默认编码更改为 Windows 1256,并选中了尝试猜测编码框...

我关闭了 vs code 并重新打开它,打开了文件夹,但文件没有按应有的方式显示。我检查了设置,就像我离开了它们(Windows 1256)

visual-studio-code encoding arabic
1个回答
0
投票

创建.vscode文件夹:

Open your workspace directory where your project files are located.
Create a new folder named .vscode. This folder will store VS Code settings specific to your project.

创建settings.json文件:

Inside the .vscode folder, create a new file named settings.json.
This file will contain the VS Code settings that override the default settings for your project.

指定编码设置:

Open the settings.json file in a text editor.
Add the following content to the file:
    {
  "files.autoGuessEncoding": false,
  "files.encoding": "windows1256"
}

此配置显式地将项目文件夹及其子文件夹中的所有文件的编码设置为“windows1256”。

保存文件:

Save the settings.json file.

测试配置:

Open VS Code and navigate to your project folder.
Open a file containing Arabic text that was previously displaying incorrectly.
The Arabic text should now display correctly with the specified encoding "windows1256".
© www.soinside.com 2019 - 2024. All rights reserved.