title: sanitizing content from open(url).read
body: <p>I am using Ruby to open a URL and read its content. The content type of the file I am reading is 'text/plain'. </p>
  
  <p>The issue is that this contains some characters which I want to escape. For example, one of the characters that is coming up in the plain text is "\240" which is ASCII for a hyphen.</p>
  
  <p>I am curious how this is being generated, because I don't see a hyphen anywhere in the text. Yet it exists invisibly and "\240" shows up when I use <code>puts</code> to print the text in the console.</p>
  
  <p>Second of all, how do I escape such instances of weird characters? Ideally, I want to escape all characters which are of the form "\[some number]". I am using </p>
  
  <pre><code>"\240".gsub(Regexp.new("\\\d+"),"")
  </code></pre>
  
  <p>but it doesn't seem to work.</p>
  
  <p>Are there more traditional ways of sanitizing plain text content read from opening a URL?</p>