title: Transcoding a string from UTF-8 to ASCII-8BIT in Ruby?
body: <p>I have to print Ruby strings <code>UTF-8</code> encoded, containing Italian language sentences, to a ESC/POS thermal printer (a printer that accept only ASCII-8BIT (1 byte) charset: <a href="http://maxdb.sap.com/doc/7_6/ca/bd35406ee32e34e10000000a155106/content.htm" rel="nofollow noreferrer">http://maxdb.sap.com/doc/7_6/ca/bd35406ee32e34e10000000a155106/content.htm</a>).</p>
  
  <p>BTW, I use Ruby 2.x (on Windows or Linux). I'm confused about how to transcode,</p>
  
  <p>by example let say the string 
  contained in a JSON UTF-8 enccoded on a remote server, 
  or contained in a template file as:</p>
  
  <pre><code>#!/bin/env ruby
  # encoding: utf-8
  
  string = "Però non è la città di Barnabù"
  </code></pre>
  
  <p>I have to translate the string (accented / internationalized 2 bytes) in 1 byte ('ASCII8-BIT' encodded)</p>
  
  <p>Any suggestion to how to do transaltion FROM UTF-8 TO ASCII8-BIT?</p>
  
  <p>I lost myself with methods like:  .force_encoding('ASCII-8BIT'), or encode(") ...</p>
  
  <p>EDIT:
  <img src="https://i.stack.imgur.com/C5oN7.jpg" alt="charset table of Epson TM-T20 printer"></p>
  
  <p>many thanks
  giorgio</p>