Home > Article > Development Tools > What should I do if vscode opens garbled characters?
What should I do if vscode opens with garbled characters?
VS code encoding settings/file garbled solution
First of all, by default, we use VS Code to open a utf-8 encoded file and a gb2312 encoded files. The gb2312 files were garbled during the period.
Recommended tutorial: vscode tutorial
VSCode usually defaults to UTF-8 encoding.
One way is to click the encoding button in the lower right corner (UTF-8 in the picture), then select Operations and Reopen with Encoding
Next, you can search in the supported encoding list. For this file that is already known to be encoded in GB2312, you can also type GB to search and click GB2312.
Then the character encoding is normal after VSCode is refreshed. At this time, the encoding indicator in the lower right corner will change. At this time, the saved file will also be modified according to this encoding.
Another method is to click File->Preferences->Settings, and then enter the user settings on the right:
"files.autoGuessEncoding ": true,
As shown in the figure, insert this line and save it.
After adding this setting, VSCode will try to guess the character set encoding when opening the file.
As shown in the picture, you can switch to a correct encoding without selecting the encoding yourself.
The above is the detailed content of What should I do if vscode opens garbled characters?. For more information, please follow other related articles on the PHP Chinese website!