views:

477

answers:

1

I am trying to clean up a string that I get from a website using mechanize

here is an except from the string with the junk characters

"Mountain</b></a><br>ΓÇÄ1hr&nbsp;39minΓÇÄΓÇÄ - Rated&nbsp;PGΓÇÄΓÇÄ - Action/Adventure/Science&nbsp;fictionΓÇÄΓÇÄ - EnglishΓÇÄ - <a href="

Does any one know where they characters come from and how I can replace them with spaces? How does ruby handle the encoding of characters?

+3  A: 

Those characters look like they might be appearing as the result of a UTF-8 encoding problem. I recommend reading Joel's excellent article The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) which will explain UTF-8 encoding and how to handle it in your code.

Greg Hewgill