title: Fastest quote-escaping implementation?
body: <p>I'm working on some code that is normalizing a lot of data.  At the end of processing, a number of key="value" pairs is written out to a file.</p>
  
  <p>The "value" part could be anything, so at the point of output the values must have any embedded quotes escaped as \".</p>
  
  <p>Right now, I'm using the following:</p>
  
  <pre><code>outstream &lt;&lt; boost::regex_replace(src, rxquotesearch, quoterepl);
  // (where rxquotesearch is  boost::regex("\"")  and quoterepl is "\\\\\"")
  </code></pre>
  
  <p>However, gprof shows I'm spending most of my execution time in this method, since I have to call it for every value for every line.</p>
  
  <p>I'm curious if there is a faster way than this.  I can't use std::replace since I'm replacing one character with two.  </p>
  
  <p>Thanks for any advice.</p>