Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem of garbled codes in javascript display

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the javascript display Chinese is garbled how to solve the relevant knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that after reading this javascript shows that Chinese is garbled how to solve the article will have a harvest, let's take a look.

Javascript display Chinese is garbled solutions: 1, select and the original document encoding consistent with the encoding way to view; 2, in the reference XX.js page "display" plus XX.js file encoding.

This article operating environment: windows7 system, javascript1.8.5 version, Dell G3 computer.

What if javascript shows Chinese garbled code? how to solve js Chinese garbled code?

① .js file shows garbled codes in Chinese

When Javascript files are edited and saved by XX.js, there is a coding scheme (such as GBK). When the encoding used when opening the file (such as UTF-8) is inconsistent with the coding scheme when saving, garbled Chinese will appear.

Solution:

(1) when opening and browsing with an editor, select the same encoding method as the original file encoding (such as GBK), and there will be no garbled code.

(2) Select the garbled XX.js in package explorer in eclipse, select properties from the right-click menu, and select the code saved with XX.js in Text file encoding (such as GBK), and it can be displayed normally.

Garbled Chinese fields in JavaScript in the pages of ② website

The Chinese display in XX.js is normal in eclipse or editor. Call XX.js on the page, and the Chinese field in the page result shows garbled code after execution.

Solution:

Add the encoding of the XX.js file to the page that references the XX.js to make it consistent with the encoding of the XX.js file itself (such as GBK).

Recommendations:

(1) when you create a new XX.js with Eclipse or Myeclipse for editing, it is recommended to change Text file encoding to UTF-8 first, and then edit and save it.

Note: the setting path of eclipse: Myeclispe Enterprise Workbench\ Files and Editors\ JavaScript\

(2) use a text document or other editor to edit and save XX.js. It is recommended to save it in UTF-8 encoding.

(3) on the page referencing XX.js, "display" plus the encoding mode of XX.js file UTF-8.

This is the end of the article on "how to solve the problem of Chinese garbled in javascript display". Thank you for your reading! I believe you all have a certain understanding of the knowledge of "javascript shows that Chinese is garbled". If you want to learn more, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report