In the ASP.NET page, you often need to link some JS files, such as:
If there is Chinese in JS, in general, it will report an error in the browser. If you don't believe you, you can try it yourself.
In fact, this is true: in the item automatically generated by vs.net, there is such a paragraph in web.config:
However, the problem is here, because we use the Chinese version of the Windows, Chinese version of the VS.NET, so the default encoding of the saved file is GB2313, so when the ASP.NET sends the JS file to the client, The encoded error will occur, resulting in an incorrect script code to the client.
The method of solving is simple, change the encoding definition in web.config to GB2312.
supplement:
JS file ESCAPE method processing encoding
Encoding String object so that they can read on all computers, escape (charstring) must be the MSTRING parameter is any String object or text to be encoded. Note The ESCAPE method returns a string value (Unicode format) containing Charstring content. All spaces, punctuation, sponary symbols, and other non-ASCII characters are replaced with% XX encoding, where xx is equal to the hexadecimal number of the character. For example, the space returns "% 20". The character value is more than 255 in% UXXXX format storage. Note that the ESCAPE method cannot be used to encode the Unified Resource Number (URI). ENCODEURI and ENCODEURICOMPONENT methods should be used to encodab. In ASP.NET To support UTF-8 You must set the language of web.config to support UTF-8
In addition, some of the databases must also be changed using data formats that support Unicode, such as nvarchar, ntext, etc. Information is recommended to use POST to transmit information, if you want to use querystring to transfer, it is best to add Server.urlencode
If a text encoding is normal, a piece of text has a problem, such as the text on the Label, and the text on the TextBox becomes garbled. In addition to the above setting, each ASPX's storage coding method is preferably consistent, it is an encoding method using UTF-8.