visual-studio-codeencodingarabic

How to fix VS Code encoding


I have many files containing Arabic characters. When I open it on any editor it does not show properly. I fixed the problem through Windows settings, and then I tried opening it with bloc note and it worked properly.

Since Vscode is way better for editing, I tried to open the files there, but the Arabic characters are not showing properly.

In the bottom right corner, I pressed ISO 8859-2 > reopen with encoding > Arabic (windows 1256), and the problem was fixed.

I tried to save with encoding but closing and opening the same file, apparently restored the default settings.

In the VScode settings, i did this: "files.autoGuessEncoding":true Also, I changed the user and workspace default encoding to Windows 1256 and I checked the box of try to guess the encoding ...

I closed vs code and reopened it, opened the folder, but the files are not showing as they should be. I checked the settings and it is like I left them (windows 1256)


Solution

  • Create a .vscode Folder:

    Create a settings.json File:

    Specify Encoding Settings:

         {
           "files.autoGuessEncoding": false,
           "files.encoding": "windows1256"
         }
    

    This configuration explicitly sets the encoding to "windows1256" for all files within your project folder and its subfolders.

    Save the File:

    Test the Configuration:

    The Arabic text should now display correctly with the specified encoding "windows1256".