title: SED grabbing special characters
body: <p>I’m trying to fix an encoding error in an archived html page. My problem is that sed is behaving strangely, as it doesn't catch special characters in the data. I tried both with and without -r switch.</p>
  
  <p>My data is the following:
  <code>Budapesti ??p?­t?©szeti Filmnapok k??l??nkiad??s</code></p>
  
  <p>The sed command:</p>
  
  <p><code>sed -i.bak 's|Budapesti.*|REPLACE|g' index.html</code></p>
  
  <p>and the result I get without recode:</p>
  
  <p><code>REPLACE�t?�szeti Filmnapok k??l??nkiad??s</code></p>
  
  <p>The result I'm expecting is:</p>
  
  <p><code>REPLACE</code></p>
  
  <p>It seems to be related to the encoding somehow. If I do <code>recode iso-8859-2 index.html</code> first, sed works fine and gets me the expected output.</p>
  
  <p>Here are the hex bytes for the <code>i ??p?­t?Šs</code> part before recode: </p>
  
  <p><code>69 20 3F 3F 70 3F AD 74 3F A9 73</code></p>
  
  <p>and after recode:</p>
  
  <p><code>69 20 3F 3F 70 3F C2 AD 74 3F C5 A0 73</code></p>
  
  <p>BTW, this is what I get without recode:</p>
  
  <p><code>REPLACE­t?Šs</code>
  <code>52 45 50 4C 41 43 45 AD 74 3F A9 73</code></p>
  
  <p>I'm using the latest gsed (GNU sed) 4.2.2.</p>