title: Why does HttpWebResponse return a null terminated string?
body: <p>I recently was using HttpWebResponse to return xml data from a HttpWebRequest, and I noticed that the stream returned a null terminated string to me.</p>
  
  <p>I assume its because the underlying library has to be compatible with C++, but I wasn't able to find a resource to provide further illumination.</p>
  
  <p>Mostly I'm wondering if there is an easy way to disable this behavior so I don't have to sanitize strings I'm passing into my xml reader.</p>
  
  <hr>
  
  <p>Edit here is a sample of the relevant code:</p>
  
  <pre><code>httpResponse.GetResponseStream().Read(serverBuffer, 0, BUFFER_SIZE);
  output = processResponse(System.Text.UTF8Encoding.UTF8.GetString(serverBuffer))
  </code></pre>
  
  <p>where processResponse looks like:</p>
  
  <pre><code> processResponse(string xmlResponse)
   {
       var Parser = new XmlDocument();
       xmlResponse = xmlResponse.Replace('\0',' '); //fix for httpwebrequest null terminating strings
       Parser.LoadXml(xmlResponse);
  </code></pre>