Home > Development Tools > VSCode > body text

VSCode Chinese comment garbled problem

青灯夜游
Release: 2020-12-21 17:49:17
forward
5637 people have browsed it

This article will introduce to you the problem of garbled Chinese comments in VSCode. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

VSCode Chinese comment garbled problem

Related recommendations: "vscode Basic Tutorial"

  • Problem Situation:
    • When using VisualStudioCode for Python development,
    • Since the format needs to be set to utf-8 when running Python, the encoding of the file is often set to utf-8.
    • When I opened it again, I found that a large number of Chinese comments had become garbled characters
    • For example:
  • ##By referring to the solutions on the Internet:
      Set to automatic recognition, no solution
    • Install gbk to utf-8, no solution either
  • Observation test:
      I found out that the compiler always opens it in GB2313 format every time it is opened.
    • When running the program, the file needs to be saved as utf-8 before it can be run.
    • So in the configuration file, set it to open in utf-8 format each time, unified encoding, and solve the problem
    • Step 1: Find the configuration file and open it
    • Step 2: Add statements in the configuration file
    • "files.encoding":"utf8"
      Copy after login
    • Step 3: Create a new file, Successfully solved the problem
    • Pay attention to whether it is utf-8
    • Close vscode and reopen
      • No garbled characters found
  • If you have any questions, please leave a message below in the comments.
    • 1. Where to add the statement, specifically where?
Before the problem is solved, there is a

suggestion that can be said:

Because this problem comes down to the final analysis It is a coding problem, that is, Chinese, so a better solution is to use English when commenting.

This can not only improve your English level, but also avoid various coding problems and focus more on the code.


VSCode has two setting methods, namely mouse operation and modifying the configuration file.

You can choose one of the methods to modify

Entrance:

English version: file->preferences->settings

Chinese version: File (in the upper left corner)->Preferences->Settings

You can see the top There is a search box

—Mouse operation

You can enter "encoding" in the search box. When you see file encoding, you can select utf-8, as follows:

—Modify the configuration file

Enter "setting.json" in the search box and click on the first option to enter, as follows:

Then, add a statement in the last line

For more programming-related knowledge, please visit:

Introduction to Programming ! !

The above is the detailed content of VSCode Chinese comment garbled problem. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!