Home>Article>Development Tools> Why is the txt garbled when I open it with vscode?
Why is the txt garbled when I open it with vscode?
Because txt uses gb232 encoding format, vscode The file is opened using UTF-8 encoding, and inconsistent encoding results in garbled characters.
Solution:
Click the encoding button in the lower right corner (UTF-8 in the picture), then select Operation and pass Reopen with Encoding
Next, you can search in the supported encoding list. For this file that is already known to be GB2312 encoded, it is also You can type GB to search and click GB2312.
and then the character encoding will be 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 solution is to click File->Preferences->Settings, and then enter the user settings on the right:
"files.autoGuessEncoding": true,
Insert this line of content and save it.
After adding this setting, VSCode will try to guess the character set encoding when opening the file. Switch to the correct encoding without having to choose the encoding yourself.
Related recommendations: "vscode usage tutorial"
The above is the detailed content of Why is the txt garbled when I open it with vscode?. For more information, please follow other related articles on the PHP Chinese website!