title: iconv gives "Illegal Character" with smart quotes -- how to get rid of them?
body: <p>I have a MySQL table with 120,000 lines stored in UTF-8 format. There is one field, product name, that contains text with many accents. I need to fill a second field with this same name after converting it to a url-friendly form (ASCII).</p>
  
  <p>Since PHP doesn't directly handle UTF-8, I'm using:</p>
  
  <pre>
  $value = iconv ('UTF-8', 'ISO-8859-1', $value);
  </pre>
  
  <p>to convert the name to ISO-8859-1, followed by a massive strstr statement to replace any accented character by its unaccented equivalent (à becomes a, for example).</p>
  
  <p>However, the original text names were entered with smart quotes, and iconv chokes whenever it comes across one -- I get:</p>
  
  <pre>
  Unknown error type: [8]
  
  iconv() [function.iconv]: Detected an illegal character in input string
  </pre>
  
  <p>To get rid of the smart quotes before using iconv, I have tried using three statements like:</p>
  
  <pre>
  $value = str_replace('â€™', "'", $value);
  </pre>
  
  <p>(â€™ is the raw value of a UTF-8 smart single quote)</p>
  
  <p>Because the text file is so long, these str_replace's cause the script to time out every single time.</p>
  
  <ol>
  <li><p>What is the fastest way to strip out the smart quotes (or any invalid characters) from a UTF-8 string, prior to running iconv?</p></li>
  <li><p>Or, is there an easier solution to this whole problem? What is the fastest way to convert a name with many accents, in UTF-8, to a name with no accents, spelled correctly, in ASCII?</p></li>
  </ol>