Microsoft KB Archive/254628

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

Article ID: 254628

Article Last Modified on 10/23/2003

-

APPLIES TO


 * Microsoft Active Server Pages 4.0, when used with:
 * 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.



Steps to Reproduce Behavior
The following example uses simplified Chinese (gb2312).   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> </li> Save the ASP page to the default Web site location on your Web server (usually C:\Inetput\Wwwroot).</li> View the page in your Web browser.</li> Enter some DBCS data, and then click the Submit button.</li></ol>

<div class="references_section">