stellard
stellard

Reputation: 5314

Removing Junk Characters from Ruby String

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?

Upvotes: 1

Views: 1345

Answers (1)

Greg Hewgill
Greg Hewgill

Reputation: 993163

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.

Upvotes: 3

Related Questions