The method of output UTF-8 content (XML) in ASP system

Source: Internet
Author: User
Tags version

The ASP's system defaults to GB2312, and sometimes the output XML encounters a problem: In most cases, XML is required to be UTF-8 format.

If we directly specify is not enough.

The correct one should be:

<%
Dim originalcoagepage
Originalcoagepage = Session.CodePage ' remembers the original CodePage (default is 936)
Session.CodePage = 65001 ' Set new CodePage (UTF-8)
Response.Charset = "UTF-8"
Response.ContentType = "Text/xml"
%>

...
<%
Session.CodePage = Originalcoagepage ' CodePage recovery
%>

Some of the online session.codepage written response.codepage, this is wrong;

In addition, some of the online does not recover Session.CodePage, most of the cases will cause problems, because in most cases, we do not specify CodePage on other Web pages, once visited the designated CodePage of the page, those who did not specify CodePage The page is also specified according to the CodePage.

Compared with <%@ codepage=936%>, Session.CodePage and only affects the current session.

Note that you must ensure that Session.CodePage = originalcoagepage This sentence can be executed to, do not midway code errors cause the program to terminate without execution.



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.