New to Ruby and am wondering how to get the following to print just the degree symbol...
require 'htmlentities'
coder = HTMLEntities.new
puts coder.decode('°')
Currently the command line (Windows) output is: °
Thanks!
New to Ruby and am wondering how to get the following to print just the degree symbol...
Currently the command line (Windows) output is: ° Thanks! |
||||
|
It looks like If you're using Ruby 1.9.2, it looks like the code is fairly straightforward (based on the String and Encoding documentation):
You might have to try a couple different encodings before you find something your console can understand. If you're on an older version of Ruby, it looks like the re-encoding is doable through Iconv (see this question - I suspect you're just going in the opposite direction). Hope this helps! |
|||||
|