In this tutorial, You learn how to change the VSCode encoding to (UTF-8, UTF-16, ANSI, ISO-8859-1, Arabic, and Japanese)
There are multiple ways we can do this
- Change encoding to the opened file
- Update encoding permanently and globally in VSCode
What is the default encoding for Visual Studio code? The default encoding is UTF-8. you can change it
How to change encoding for an open file in VS Code
In this approach, You can change the encoding for a single file or opened file.
Open a file in Visual Studio Code, If the file is not opened, The below option is not visible
You will see the UTF-8
text in the bottom bar of the Visual Studio code
- Clicking on the UTF-8 label, you will see two options as seen below
Select One of the options below
- Reopen with Encoding- The file is reopened with the selected encoding
- Save with Encoding - The file is saved with the selected encoding. you can choose one of the options from above.
Again one more popup appears to select encoding from all encoding lists as seen below
you can select one from the list i.e. Japanese or Korean or your required one.
That’s it, the file will be opened or saved with the selected encoding
This approach only works for a single file.
What is the shortcode to change the encoding in VSCODE? Alternatively, you can change the encoding with a single file for the below command CTRL+SHIFT+P command and type encoding and select Reopen or save with encoding option
Set Encoding globally in Visual Studio Code
Go to Settings in Visual Studio code
In Windows, you can select
File
->Preferences
-> Settings Alternatively, you can open using short keys(CTRL + ,
) CommandIn MAC:- Code -> Preferences -> Settings Alternatively, you can open using short keys(
Command +,
) CommandIt opens a settings window types
encoding
and changes the default encoding from a given list on theFiles: Encoding
option as seen below
This changes encoding globally in VSCode and newly created files will be saved with the new encoding.