title: Why is a UTF-8 string not equal to the equivalent ASCII-8BIT string in Ruby 2.0?
body: <p>I am using Ruby 2.3:</p>
  
  <p>I have the following string: <code>"\xFF\xFE"</code></p>
  
  <p>I do a <code>File.binread()</code> on a file containing it, so the encoding of this string is <code>ASCII-8BIT</code>. However, in my code, i check to see whether this string was indeed read by comparing it to the literal string <code>"\xFF\xFE"</code> (which has encoding <code>UTF-8</code> as all Ruby strings have by default).</p>
  
  <p>However, the comparison returns <code>false</code>, even though both strings contain the same bytes - it just happens that one is with encoding <code>ASCII-8BIT</code> and the other is <code>UTF-8</code></p>
  
  <p>I have two questions: (1) why does it return <code>false</code> ? and (2) what is the best way to go about achieving what i want? I just want to check whether the string I read matches <code>"\xFF\xFE"</code></p>