title: Classic ASP response.write or response.Binarywrite having problems with chr(0)
body: <p>I am having an issue with writing a file to the response object. The file is Base64 encoded and is being sent to the ASP code via a web service.</p>
  
  <pre><code>dim contentType, fileName
  
  filename = request("FileName")
  contentType = request("ContentType")
  If Not Response.isClientConnected Then
      Response.end
  End If
  Response.buffer = true
  Response.Clear
  Response.Addheader "Content-Disposition", "attachment; filename=" &amp; filename
  Response.contenttype = contentType
  
  dim oSoapClient
  Set oSoapClient = Server.CreateObject("MSSOAP.SoapClient")
  oSoapClient.ClientProperty("ServerHTTPRequest") = True
  oSoapClient.mssoapinit "http://myWS/test.asmx?WSDL"
  dim sRequest, sResponse
  sRequest = "&lt;Root&gt;&lt;Attachment id=""" &amp; Request("ID") &amp; """/&gt;&lt;/Root&gt;"          
  sResponse = oSoapClient.GetAttachment(sRequest)  
  Dim oXML: Set oXML = LoadXMLString(sResponse)
  
  Dim oAttachment
  set oAttachment = oXML.SelectSingleNode("/Root/Attachment")
  if not oAttachment is nothing then
      Response.Binarywrite(Base64Decode(oAttachment.attributes.getNamedItem("BinaryData").value))
  
  End if
  Response.End
  </code></pre>
  
  <p>The BinaryWrite is adding extra null characters every other byte.  Change it to response.write and it does not put the nulls but terminates the string if a null character is found.  </p>
  
  <p>I'm looking for a method to use the binarywrite without it adding the extra nulls.  Is it a charset issue?</p>
  
  <p>Thanks</p>