title: Python: Removing particular character (u"\u2610") from string
body: <p>I have been wrestling with decoding and encoding in Python, and I can't quite figure out how to resolve my problem. I am looping over xml text files (<a href="https://github.com/lofhm/ECCO-TCP/blob/master/xml/K000039.000.xml" rel="nofollow">sample</a>) that are apparently coded in utf-8, using Beautiful Soup to parse each file, then looking to see if any sentence in the file contains one or more words from two different list of words. Because the xml files are from the eighteenth century, I need to retain the em dashes that are in the xml. The code below does this just fine, but it also retains a pesky box character that I wish to remove. I believe the box character is <a href="http://www.fileformat.info/info/unicode/char/2610/index.htm" rel="nofollow">this character</a>. </p>
  
  <p>(You can find an example of the character I wish to remove in line 3682 of the sample file above. On this webpage, the character looks like an 'or' pipe, but when I read the xml file in Komodo, it looks like a box. When I try to copy and paste the box into a search engine, it looks like an 'or' pipe. When I print to console, though, the character looks like an empty box.)</p>
  
  <p>To sum up, the code below runs without errors, but it prints the empty box character that I would like to remove. </p>
  
  <pre><code>for work in glob.glob(pathtofiles):
  
      openfile = open(work)
      readfile = openfile.read()
      stringfile = str(readfile)
  
      decodefile = stringfile.decode('utf-8', 'strict') #is this the dodgy line?
      soup = BeautifulSoup(decodefile)
  
      textwithtags = soup.findAll('text')
  
      textwithtagsasstring = str(textwithtags)
  
      #this method strips everything between anglebrackets as it should
      textwithouttags = stripTags(textwithtagsasstring)
  
      #clean text
      nonewlines = textwithouttags.replace("\n", " ")
      noextrawhitespace = re.sub(' +',' ', nonewlines)
  
      print noextrawhitespace #the boxes appear
  </code></pre>
  
  <p>I tried to remove the boxes by using </p>
  
  <pre><code>noboxes = noextrawhitespace.replace(u"\u2610", "")
  </code></pre>
  
  <p>But Python threw an error flag:</p>
  
  <pre><code>UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 280: ordinal not in range(128)
  </code></pre>
  
  <p>Does anyone know how I can remove the boxes from the xml files? I would be grateful for any help others can offer.</p>