Recommended: Methods of using SQL statements in ASP dynamic web page production 1. SELECT statement In the SQL world, the most basic operation is the SELECT statement. When using SQL directly under the database tool, many people will be familiar with the following operations: The following is the quoted content:
Why does it often display garbled code in ASP when specifying codepage as 65001? The talented man will explain this issue in detail here so that many friends will avoid taking detours and even rejecting UTF-8.
If you don’t know what UTF-8 is yet, then Caizi suggests that you search for UTF-8’s related information first.
It is certainly reasonable that UTF-8 encoding is accepted and even liked by more and more people. Today, when WEB2.0 is popular, while talking about multi-browser compatibility, I have to think that the garbled phenomenon caused by different character encodings also needs to be handled well...
N years ago, all versions below IE6 would be garbled if they did not have the corresponding font library installed. For example, I am the version of IE5 (Windows2000 default). Without the IE traditional font library installed, websites that access any traditional page would be garbled if they would not have the IE traditional font library installed. Of course, the premise is that the page uses BIG5's Charset, and UTF-8 can handle this problem well as an international encoding. As long as the page is saved as UTF-8 encoding format, and then define the codepage and charset as utf-8 on the page, you can display the completely correct content in any client browser, and there will be no garbled...
OK, here we take the ASP page as an example, and let’s take an example to see the specific operation:
Open a new ASP page, I believe that friends who play ASP will notice that in many downloaded source codes, there is usually a sentence at the top of the page:
| The following is the quoted content: %@LANGUAGE=VBSCRIPT CODEPAGE=936% |
There is no need to say much about the previous language. vbscript is the default scripting language for ASP. In fact, it is completely unnecessary to write. If written, it may also affect the page execution efficiency. We will not discuss this issue here. The codepage behind is the key, and the purpose is to tell the browser what kind of encoding this page is. 936 means simplified Chinese, while 950 means traditional Chinese, and 65001 is the UTF-8 encoding we are talking about today. We changed 936 to 65001. The whole sentence is as follows:
| The following is the quoted content: %@LANGUAGE=VBSCRIPT CODEPAGE=65001% |
Add to output a few Chinese characters to see if they can be displayed correctly.
| The following is the quoted content: <% Response.Write Test UTF-8 page for the first time %> |
OK, just click Save and execute this page to see. If nothing unexpected happens, you may see that the words UTF-8 pages are displayed, and there is garbled Chinese. What is the reason?
OK, please click on the file menu at the top and select Save As. There is an encoding on the bottom line. The default should be ANSI. Please click the drop-down box, select UTF-8, click Save, and then try it out. If nothing unexpected happens, it will be even more messy. Haha, you're dizzy. Don't worry, think about the reason, because the page we made is returned by HTML. In the past, when we wrote HTML, we saw a sentence meta in front of the body, that is, in the head, which should be like this:
| The following is the quoted content: <meta http-equiv=Content-Type content=text/html; charset=gb2312> |
That is, the specified page returns the result with gb2312 encoding, and must be written in front of the output with the return result. Everyone knows that gb2312 is simplified Chinese. Today we are talking about UTF-8 encoding. Let’s change gb2312 to UTF-8. The whole code is as follows:
| The following is the quoted content: <%@LANGUAGE=VBSCRIPT CODEPAGE=65001%> <meta http-equiv=Content-Type content=text/html; charset=utf-8> <% Response.Write Test UTF-8 page for the first time %> |
Execute again, well, it will be displayed normally this time...
Conclusion: In order to use UTF-8 encoding, in addition to saving the file as UTF-8 format, you also need to specify codepage and charset at the same time.
Share: Use SQL-DMO to create backup and verification ASP applications Overview SQL Distributed Management objects (SQL-DMO) provide developers with methods to perform ordinary tasks using program and scripting languages, thus extending the functionality of SQL Server. This article talks about how to cleverly use SQL-DMO to create