BUG: Double-Byte Character Set Data May Be Corrupted When You Assume Request Object Collection Name (254628)



The information in this article applies to:

  • Microsoft Active Server Pages, when used with:
    • the operating system: Microsoft Windows NT 4.0

This article was previously published under Q254628

SYMPTOMS

When a Web browser submits an HTML form that contains double-byte character set (DBCS) data to an Active Server Pages (ASP) page, the data may become corrupted.

CAUSE

This problem can occur if the ASP code uses the Request object with an assumed collection name when the collection is first accessed.

For example, this problem can occur if a form with Chinese characters is posted to an ASP page, and you first use Request("myformelement") instead of Request.Form("myformelement") to retrieve the posted data. ASP uses the default system code page (instead of the code page that is specified in the ASP code) to interpret the data.

NOTE: On an English Microsoft Windows NT-based system, the default system codepage is Windows-1252.

RESOLUTION

There are three ways to resolve this issue:
  • Upgrade to Microsoft Windows 2000.
  • Always specify the collection name, for example, Request.Querystring("myfield").
  • If you must assume collection names, initialize access to each collection that you use on the page by name. To do this, insert code at the top of any page to access the collection or collections by name by using a field name such as "nullField" that does not necessarily exist in the collection. The following code demonstrates this technique:
    <%
    Request.Form("nullField")
    Request.QueryString("nullField")
    Request.Cookies("nullField")
    %>

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce Behavior

The following example uses simplified Chinese (gb2312).
  1. Create a new ASP page and paste the following code:
    <%@ Language=VBScript codepage=936%>
    <%
    Response.Write("Your posted data is:  " & Request.Form("txtValue"))
    %>
    <HTML>
    <HEAD>
    <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    </HEAD>
    <BODY>
    
    <FORM id=FORM1 name=FORM1 action="" method=post>
    <P><INPUT id=txtValue name=txtValue></P>
    <P><INPUT type="submit" value="Submit" id=submit1 name=submit1></P>
    </FORM>
    
    </BODY>
    </HTML>
    					
  2. Save the ASP page to the default Web site location on your Web server (usually C:\Inetput\Wwwroot).
  3. View the page in your Web browser.
  4. Enter some DBCS data, and then click the Submit button.

REFERENCES

For additional information on ASP related localization resources, click the article numbers below to view the articles in the Microsoft Knowledge Base:

254313 PRB: Error Message: Active Server Pages Error 'ASP 0203' Invalid Code Page

261154 PRB: Visual InterDev Design-Time Controls Corrupt Unicode and Double-Byte Character Set Data

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


Modification Type:MajorLast Reviewed:10/23/2003
Keywords:kbASPObj kbBug kbCodeSnippet kbLocalization kbnofix kbWebServer KB254628 kbAudDeveloper