PRB: Server.HTMLEncode Corrupts Unicode Characters and Double-Byte Character Set Data

Article translations Article translations
Article ID: 259352 - View products that this article applies to.
This article was previously published under Q259352
Expand all | Collapse all

On This Page

SYMPTOMS

When you use Server.HTMLEncode in the server-side script of an Active Server Pages (ASP) page that contains Unicode or double-byte character set (DBCS) data, you may find that the data gets corrupted.

CAUSE

The ASP Server.HTMLEncode method does not recognize Unicode and DBCS data formats and converts the data as if it were in single-byte character set (SBCS) format.

NOTE: The Server.HTMLEncode method on Windows 2000 platforms does recognize DBCS data formats. So, for Windows 2000, only Unicode data is converted as if it is in SBCS format.

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Create an ASP page, and paste the following code into the page:
    <%@ Language=VBScript codepage=950%>
    <!--
    This example uses a Chinese (Big5) Charset
    -->
    <%
    Session.CodePage = 950
    %>
    <HTML>
    <HEAD>
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=big5">
    </HEAD>
    <BODY>
    <FORM action="" method=post id=FORM1 name=FORM1>
    <INPUT id=txtValue name=txtValue>
    <INPUT id=submit1 name=submit1 type=submit value=Submit> 
    </FORM>
    <HR>
    <%
    Response.Write(Server.HTMLEncode(Request.Form("txtValue")))
    %>
    </BODY>
    </HTML>
    					
  2. View the ASP page in a Web browser.
  3. Enter a Chinese character into the HTML textbox, and then click Submit.

REFERENCES

For additional information concerning Server.HTMLEncode, click the article number below to view the article in the Microsoft Knowledge Base:
184891 Server.HTMLEncode Garbles Extended Characters
For more information concerning charsets and code pages, please see the following MSDN article:
Character Set Recognition
http://msdn2.microsoft.com/en-us/library/Aa752010.aspx

Properties

Article ID: 259352 - Last Review: May 18, 2007 - Revision: 3.2
APPLIES TO
  • Microsoft Active Server Pages 2.0, when used with:
    • Microsoft Internet Information Server 4.0
    • Microsoft Internet Information Services 5.0
Keywords: 
kblocalization kbprb KB259352

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com