ASP codepage page encoding and asp.net page encoding description

Source: Internet
Author: User

If you want to set the page encoding for the entire project, you can add a globalization property to the Web.config file, and then set its fileencoding, requestencoding, and responseencoding attributes:

<configuration>
<system.web>
<globalization
Fileencoding= "Utf-8"
Requestencoding= "Utf-8"
Responseencoding= "Utf-8"
Culture= "en-US"
Uiculture= "De-de"
/>
</system.web>
</configuration>


To set the encoding for a separate page, you can set the requestencoding and responseencoding attributes of the @ Page directive:
<%@ Page requestencoding= "Utf-8" responseencoding= "Utf-8"%>

Sometimes we have set the entire site encoding to gb2312 in the configuration file, but a page needs to use Utf-8, and then we can add the location node under the configuration file configuration:
Program code

<location path= "test.asp tutorial X" >
<system.web>
<globalization fileencoding= "Utf-8" requestencoding= "Utf-8" responseencoding= "Utf-8" culture= "en"/>
</system.web>
</location>


If you want to set a page individually as gb2312:
Program code <location path= "Test.aspx" >

<system.web>
<globalization fileencoding= "gb2312" requestencoding= "gb2312" responseencoding= "gb2312" culture= "ZH-CN"/>
</system.web>
</location>

The following is a number of users to solve the problem of the method reference:

In the use of ASP.net to write online payment interface program, encountered a strange problem, through the form submitted in the past Chinese is garbled, English normal. and the ASP program to test, you can submit the normal Chinese, ASP page has such HTML code:

< meta HTTP-EQUIV = "Content-type" Content = "text/html charset=gb2312" >

But adding this code to the ASP.net page still doesn't solve the problem. Analysis, the problem should be caused by coding, the other side of the program can only handle the GB2312 encoded pages submitted by the Chinese data. Did you add the above code, ASP. NET is not shown in GB2312 encoding? Open the page, check the browser's encoding, the original is UTF-8, the reason to find, how to solve it? It seems that ASP. NET ignore the above code, to send the encoding information to the browser, I set the response.contentencoding to try, add the following code in the Page_Load:

response.contentencoding = System.Text.Encoding.GetEncoding ("GB2312");


Let's look at the ASP page encoding instructions

codepage=936 Simplified Chinese GBK
codepage=950 Traditional Chinese BIG5
codepage=437 American/Canadian English
codepage=932 Japanese
codepage=949 Han Wen
codepage=866 Russian
codepage=65001 Unicode UFT-8

Use of page encoding:
Based on VBScript

VBScript
<% @LANGUAGE = "VBSCRIPT" codepage= "65001"%>
JavaScript tutorials
<% @LANGUAGE = "JAVASCRIPT" codepage= "65001"%>

Here are some additional notes:

Role

Let the ASP read form submissions, database tutorials, etc. in a specific encoding.

How to use

Join in the first line of the ASP file. Based on the different code pages, use the following code:

<%@ codepage=936%> Simplified Chinese
<%@ codepage=950%> Traditional Chinese
<%@ codepage=65001%> UTF-8

Use attention

If page A does not set codepage, the page B and C set the codepage. When you first visit page A, use the IIS default codepage, and then visit page B with the codepage specified by page B, and then when you visit page A, you still use the codepage specified by page B, and the last visit to page C, using the codepage specified by page C.

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.