If the ASP program is in the same site and there is a UTF-8 encoded program and a GB2312 encoded program, after browsing the UTF-8 encoded page and then browsing the GB2312 page of the current website, the GB2312 encoded page will appear. Garbled characters
The problem is that when you browse UTF-8 encoding, the server uses the UTF-8 engine to output HTML by default. When you browse the GB2312 page, it still uses UTF-8 to output the GB2312 encoding. The page will be garbled.
This problem bothered me all morning, and finally the blue ideal was solved.
First, let's take a look at the four properties provided by the Session object.
1.CodePage read/write. Integer type.
Defines the code page used to display page content in the browser. A code page is the numerical value of a character set, and different languages and locations may use different code pages. For example, ANSI code page 1252 is used for US English and most European languages. Code page 932 is used for Japanese characters. (This is the attribute we are going to use here)
2.LCID read/write. Integer type.
Defines the page locale identifier (LCID) sent to the browser. LCID is an international standard abbreviation that uniquely identifies a region. For example, 2057 defines the currency symbol of the current region as '£'. LCID can also be used in statements such as FormatCurrency, as long as there is an optional LCID parameter. LCID can also be set in the ASP processing directive <%...%>, and takes precedence over the setting in the session's LCID attribute. A list of ASP processing instructions is provided later in this chapter.
3.SessionID is read-only. Long type.
Returns the session identifier for this session, generated by the server when the session was created. Unique only during the lifetime of the parent Application object, so it can be reused when a new application starts
4.Timeout read/write. Integer type.
Defines the timeout period in minutes for this session. If the user does not refresh or request a web page within the timeout period, the session ends. It can be modified in each web page as needed. The default value is 10min. This time should be shorter on sites with high usage!
Here are some commonly used ANSI code pages:
<%@ codepage=65001%>UTF-8
<%@ codepage=936%>Simplified Chinese
<%@ codepage=950%>Traditional Chinese
<%@ codepage=437 %>US/Canada English
<%@ codepage=932 %>Japanese
<%@ codepage=949 %>Korean
<%@ codepage=866 %>Russian
Now let’s talk about the methods and uses to solve the problem.
Add the following code to the shared file conn.asp used in the website program:
1. Added to Gb2312 encoding page
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%Session.CodePage=936%>
Finally add more
<%Response.charset = "BG2312"%>
2. Add <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> to the utf-8 encoding page
<%Session.CodePage=65001%>
<%Response.charset = "utf-8"%>
This is the simplest and most effective method.