title: Ruby incompatible character encodings
body: <p>I am currently trying to write a script that iterates over an input file and checks data on a website. If it finds the new data, it prints out to the terminal that it passes, if it doesn't it tells me it fails. And vice versa for deleted data. It was working fine until the input file I was given contains the "™" character. Then when ruby gets to that line, it is spitting out an error:</p>
  
  <blockquote>
    <p>PDAPWeb.rb:73:in `include?': incompatible character encodings: UTF-8 and IBM437
    (Encoding::CompatibilityError)</p>
  </blockquote>
  
  <p>The offending line is a simple check to see if the text exists on the page. </p>
  
  <pre><code>if browser.text.include? (program_name)
  </code></pre>
  
  <p>Where the program_name variable is a parsed piece of information from the input file. In this instance, the program_name contains the 'TM' character mentioned before. </p>
  
  <p>After some research I found that adding the line # encoding: utf-8 to the beginning of my script could help, but so far has not proven useful. </p>
  
  <p>I added this to my program_name variable to see if it would help(and it allowed my script to run without errors), but now it is not properly finding the TM character when it should be. </p>
  
  <pre><code>program_name = record[2].gsub("\n", '').force_encoding("utf-8").encode("IBM437", replace: nil)
  </code></pre>
  
  <p>This seemed to convert the TM character to this: Γäó</p>
  
  <p>I thought maybe i had IBM437 and utf-8 parts reversed, so I tried the opposite </p>
  
  <pre><code>program_name = record[2].gsub("\n", '').force_encoding("IBM437").encode("utf-8", replace: nil)
  </code></pre>
  
  <p>and am now receiving this error when attempting to run the script</p>
  
  <blockquote>
    <p>PDAPWeb.rb:48:in `encode': U+2122 from UTF-8 to IBM437 (Encoding::UndefinedConve
    rsionError)</p>
  </blockquote>
  
  <p>I am using ruby 1.9.3p392 (2013-02-22) and I'm not sure if I should upgrade as this is the standard version installed in my company. </p>
  
  <p>Is my encoding incorrect and causing it to convert the TM character with errors? </p>