title: How to remove special characters in python?
body: <p>I am facing an issue in below code due to special characters(�) in description.Because of these special character i am getting an error.</p>
  
  <p><strong>Error: 'ascii' codec can't decode byte 0x94 in position 821: ordinal not in range(128)
  Please help me to remove this error.</strong></p>
  
  <p>Data in text form and data in html form given below respectively </p>
  
  <p>Link: <a href="http://m.cellularoutfitter.com/p-85870-anycom-solar-bluetooth-car-kit_c.html" rel="nofollow">http://m.cellularoutfitter.com/p-85870-anycom-solar-bluetooth-car-kit_c.html</a> (having descripton at the end of page)</p>
  
  <p>I have tried various methods and encodings but failed.</p>
  
  <p>First i get the complete src of link then By using x path I get the description in a variable.
  i can not post the complete code because of some reasons. Sorry </p>
  
  <p>Python code:</p>
  
  <pre><code>parser = etree.HTMLParser(remove_blank_text=True, encoding="utf-8")
  tree = etree.HTML(popup_html, parser)
      description = tree.xpath("//span[@itemprop='description' and not(src)] ")
  
  log.debug(str(description[0]))
  for desc in description:
      log.debug(etree.tostring(desc,encoding='UTF-8'))
      if etree.tostring(desc,encoding='UTF-8').find("IFRAME") &lt; 0:
          reply_dict['product_desc'] = reply_dict['product_desc'] + etree.tostring(desc,encoding='UTF-8')
          reply_dict['product_desc'] = reply_dict['product_desc'].replace("&amp;#13;\n", "").replace("\n", "&lt;br/&gt;").replace("img","").replace('&lt; src="/productPics/altImgs/decal-skin-pdp-2.jpg"/&gt;',"")
          reply_dict['product_desc'] = reply_dict['product_desc'].replace("\xef\xbf\xbd","'")
          reply_dict['product_desc'] = reply_dict['product_desc'].replace("\x92","'")
          reply_dict['product_desc'] = "&lt;br /&gt;".join(reply_dict['product_desc'].split("\n")).replace("     ", "&amp;nbsp;").encode('ascii', 'xmlcharrefreplace')
  </code></pre>
  
  <p>HTML Code:</p>
  
  <pre><code>&lt;div class="centerContain"&gt;
              Convenient Bluetooth car kit easily mounts to vehicle windshield and features high-performance solar panel capable of converting UV rays into Bluetooth battery power. What's included: ANYCOM Solar Bluetooth Car Kit, window mount, suction cups, 12/24V vehicle power adapter w/USB cable, 3M adhesive tape, user guide.
              &lt;ul&gt;
                  &lt;li&gt;Solar panel recharges battery, providing 30 minutes of talk time for every 3 hours of sun light&lt;/li&gt;&lt;li&gt;Features Digital Signal Processing (DSP) technology, including compression and echo cancellation&lt;/li&gt;&lt;li&gt;Easily pairs with compatible devices&lt;/li&gt;&lt;li&gt;Bluetooth: v2.0&lt;/li&gt;&lt;li&gt;Talk Time: 15 hours&lt;/li&gt;&lt;li&gt;Standby Time: 25 days&lt;/li&gt;&lt;li&gt;Operating Range: 33 ft. (10 meters)&lt;/li&gt;&lt;li&gt;Size: 3.59� (H) x 1.98� (W) x 0.52� (D)&lt;/li&gt;&lt;li&gt;Weight: 2.11 oz.&lt;/li&gt;&lt;li&gt;Warranty: ANYCOM limited worldwide 2-year warranty&lt;/li&gt;
              &lt;/ul&gt;
          &lt;/div&gt;
  </code></pre>
  
  <p>In text Form:</p>
  
  <p>Convenient Bluetooth car kit easily mounts to vehicle windshield and features high-performance solar panel capable of converting UV rays into Bluetooth battery power. What's included: ANYCOM Solar Bluetooth Car Kit, window mount, suction cups, 12/24V vehicle power adapter w/USB cable, 3M adhesive tape, user guide.
  Solar panel recharges battery, providing 30 minutes of talk time for every 3 hours of sun light
  Features Digital Signal Processing (DSP) technology, including compression and echo cancellation
  Easily pairs with compatible devices
  Bluetooth: v2.0
  Talk Time: 15 hours
  Standby Time: 25 days
  Operating Range: 33 ft. (10 meters)
  Size: 3.59� (H) x 1.98� (W) x 0.52� (D)
  Weight: 2.11 oz.
  Warranty: ANYCOM limited worldwide 2-year warranty</p>