Solution of UTF-8 page garbled under ASP Dynamic Web page

Source: Internet
Author: User
Tags format
Dynamic | solution | page | page

Why in the ASP to specify the codepage 65001 also often display garbled. Wit here will explain this problem in detail, lest many friends again detours, and even repel UTF-8.

If you do not know what UTF-8 is, then the wit suggested that you go to search the relevant information UTF-8.

UTF-8 coding is more and more people accept even like, certainly is reasonable, in the WEB2.0 prevalent today, in large talk about the compatibility of multiple browsers at the same time, have to think of different character encoding caused by the garbled phenomenon also need to be very good treatment ...

N years ago, IE6 all the following versions, as long as the corresponding font is not installed, access to related pages are garbled, for example, I am IE5 (Windows2000 default) version, in the absence of the installation of IE Traditional Chinese library, access to any traditional Web site will be garbled, Of course, the premise is that the page uses the BIG5 charset, and UTF-8 as an international code can be very good to deal with the problem, as long as the page is stored as a UTF-8 encoding format, Then on the page on the codepage and charset all defined as Utf-8 can be in any client browser to display exactly the right content, completely not garbled ...

OK, here take the ASP page for example, take an example to see the specific operation bar:

Open a new ASP page, I believe that playing ASP's friends will notice that many downloads of the source code, the top of the page generally have a sentence:

<% @LANGUAGE = "VBSCRIPT" codepage= "936"%>

The front of the language should not say more, VBScript is the ASP default scripting language, in fact, can not write, write as if it will affect the efficiency of the page execution, here we do not discuss this issue. The codepage is the key, the purpose is to tell the browser, this page is what the code, 936 of the representative is simplified Chinese, and 950 for Traditional Chinese, 65001 is what we say today UTF-8 code. We'll change 936 to 65001, the whole sentence as follows:

<% @LANGUAGE = "VBSCRIPT" codepage= "65001"%>

Plus the output of several Chinese text to see if you can correctly display it.

<%
Response.Write "First Test UTF-8 page"
%>

OK, directly click "Save", the implementation of this page to see if there is no accident, we may see the display is "a UTF-8 page" of these words, Chinese have garbled phenomenon, what reason?

OK, please click on the top of the "File" menu, select "Save As", the bottom line has a code, the default should be ANSI, please point down the box, select UTF-8, and then save, then try to do, if not an accident, chaos more powerful, oh, dizzy it. Don't worry, think about why, Because we do the page is returned by HTML, before we write HTML, see the body front, that is, head has a meta, should be this:

<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">

That is, specify the page to return the result in gb2312 encoding, be sure to write in the back of the output of the return results. We all know gb2312 is Simplified Chinese, we say today is UTF-8 code, we will gb2312 to UTF-8 it, all the code is as follows:

<% @LANGUAGE = "VBSCRIPT" codepage= "65001"%>
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
<%
Response.Write "First Test UTF-8 page"
%>

Take a look at it again, well, this time the normal show ....

Conclusion: In addition to saving the file as UTF-8 format, it is necessary to specify codepage and charset at the same time using UTF-8 coding.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.