<p>this wiki page gave a general idea of how to convert a single char to ascii <a href="http://en.wikibooks.org/wiki/Ruby_Programming/ASCII" rel="noreferrer">http://en.wikibooks.org/wiki/Ruby_Programming/ASCII</a></p>

<p>But say if I have a string and I wanted to get each character's ascii from it, what do i need to do?</p>

<pre><code>"string".each_byte do |c|
      $char = c.chr
      $ascii = ?char
      puts $ascii
end
</code></pre>

<p>It doesn't work because it's not happy with the line $ascii = ?char</p>

<pre><code>syntax error, unexpected '?'
      $ascii = ?char
                ^
</code></pre>

The
```
c
```
variable already contains the char code!
```
```
"string".each_byte do |c|
    puts c
end
```
```
yields
```
```
115
116
114
105
110
103
```
```