My page today also had garbled characters, so I searched for related problems on the Internet. It seems that this method is quite good. I also tried it. I used the editp editor. In Document-File Encoding-Change File Encoding-Select the encoding you need. On web pages, the problem of garbled Chinese characters often occurs. When I encountered garbled characters in the past, I would keep trying different encoding methods until I succeeded. The project encountered this problem again yesterday, so I did a simple test. HTML files have encoding methods, such as "UTF-8", "GBK" and so on. These may not be visible in Notepad, but in Eclipse, you can set the encoding method of the HTML file, which will be explained in the following picture. Test 1: Save the html file in "UTF-8" mode. See the figure below for the specific file content: As you can see in the figure, the file encoding is "UTF-8", and the "Other" in the red box below is set in eclipse. The red box above the image indicates the encoding method used by the browser to open the file, which can be seen as "UTF-8". Open the file using IE and you can see the following image: Check the browser's encoding method and you can see that the browser automatically selects the "UTF-8" method and no garbled characters appear. Switch the browser encoding to "GB2312", and you can see the following picture: Test 2: Save the HTML file in "UTF-8" mode, and set the encoding in the file header to "GBK", as shown below: This indicates that the file encoding is "UTF-8" and the default file opening method is "GBK". The screenshot of opening this file using IE is as follows: You can see that the browser opens it in "GB2312" mode according to the instructions of the HTML file. Since the file itself is encoded in "UTF-8", garbled characters appear. But the source file of the web page is not garbled. Select "UTF-8" as the encoding method of the browser, and you can see that the garbled characters disappear. The screenshots are as follows: This concludes the test. Summarize the following points: 1. HTML files have an encoding format, which can only be seen and set in a specific editor. 2. The "charset" set in the "content-type" in the header of the HTML file tells the browser the encoding method to use when opening the file. 3. Generally, the encoding methods in points 1 and 2 should be consistent. If they are inconsistent, garbled characters may appear. 4. If garbled characters are displayed in the browser, but the source file of the page is not garbled, you can see the correct Chinese by changing the encoding method of the browser. If the correct "charset" is set in the source file, there is no need to change the encoding method of the browser. |
<<: Javascript destructuring assignment details
>>: Solve the problem of Navicat for Mysql connection error 1251 (connection failed)
Core SQL statements MySQL query statement that do...
illustrate MySql Community Edition supports table...
React Native is a cross-platform mobile applicati...
This article shares the specific code of JavaScri...
Table of contents Summarize <template> <...
The final result is like this, isn’t it cute… PS:...
Table of contents 1. Introduction to label statem...
The application of containers is becoming more an...
Preface nginx uses a multi-process model. When a ...
Frame structure tag <frameset></frameset...
GitHub address: https://github.com/dmhsq/dmhsq-my...
First, your container must be running You can vie...
Table of contents Primary key constraint Unique p...
This article shares the specific code of jQuery t...
Preface Fix the footer area at the bottom. No mat...