Microsoft KB Archive/259352

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

Article ID: 259352

Article Last Modified on 5/18/2007

-

APPLIES TO

 Microsoft Active Server Pages 2.0, when used with:  Microsoft Internet Information Server 4.0

 Microsoft Internet Information Services 5.0 

-



This article was previously published under Q259352



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.

<div class="moreinformation_section">

Steps to Reproduce Behavior
<ol>  Create an ASP page, and paste the following code into the page: <%@ Language=VBScript codepage=950%>

<% Session.CodePage = 950 %> <HTML> <HEAD> <META HTTP-EQUIV=&quot;Content-Type&quot; CONTENT=&quot;text/html; CHARSET=big5&quot;> </HEAD> <BODY> <FORM action=&quot;&quot; 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(&quot;txtValue&quot;))) %> </BODY> </HTML> </li> View the ASP page in a Web browser.</li> Enter a Chinese character into the HTML textbox, and then click Submit.</li></ol>

<div class="references_section">