title: std::string.append("\r\n\r\n") adds c62;9;c62;9; to end of string?
body: <p>I am trying to append the sentinel ("\r\n\r\n") for an HTTP response to a <code>std::string</code> in C++. However, when I append the data, I get a whole bunch of extra stuff: <code>^[[?62;9;c^[[?62;9;c[</code>, followed by my programs termination. Then it writes the following to the command line: <code>62;9;c62;9;c62;9;c62;9;c62;9;c62;9;c</code>. This only seems to happen with <em>.jpg/</em>.gif files, I have tested and verified the same method working with text and html files. </p>
  
  <p>The context is that I am trying to write this string to a socket, using <code>string.c_str()</code>. I have traced the extra characters to the append operation that I do, after reading the desired file. I think this is throwing my calculated content-length off, causing the crash. So I just need to know why this extra stuff ends up in my <code>string.c_str()</code>?</p>
  
  <p><strong>EDIT:</strong> Here is my file reading code. (Forgot to paste it)(BUFFER_LENGTH is #defined as 1024)</p>
  
  <pre><code>    int fd = open(filename.c_str(),O_RDONLY);
      int bytesRead = 0;
      char buffer[BUFFER_LENGTH];
      string content = "";
      while((bytesRead = read(fd, buffer, BUFFER_LENGTH)) !=0)
      {           
          if(bytesRead==-1)
          {
              if(errno == EINTR)
              {
                  printf("\nERRONO");
                  continue;
              }
              else
              {
                  printf("\nclosing fd");
                  close(fd);
              }
          }  
          content+= buffer;
      }
      close(fd);
      //Printing content.c_str() here gives right value
      content += "\r\n\r\n";
      //Printing content.c_str() here gives the gibberish, and crash when I write it to the socket.
      return content;
  </code></pre>
  
  <p>Here is how I write to the socket(fdToUse is the socket):</p>
  
  <pre><code>write(fdToUse, response-&gt;fullResponse.c_str(), response-&gt;fullResponse.length());
  close(fdToUse);
  </code></pre>