'Special' characters - £ sign showing as ú

Hiya All,

Continuing on learning the basics of Ruby I’ve stumbled on a common
issue I can’t seem to resolve. Searched and made some progress but not
quite cracked it.

I have a line in my code that is:

puts “The current sale price is #{163.chr}#{rand(10)*2},000 - cash only

I’m looking to have the pound symbol shown (£) but it comes out as an
accented u (ú). I understood that Ruby was using 8859-1 table

However, in testing out various characters I see anything above 126
doesn’t appear as expected.

So to ask the question; how can I get the £ symbol (and perhaps others)
to print out?

I’m running Win 7, testing through a CMD window, with Ruby 1.9.2

Full code at - http://codepad.org/Tq9zLBm3

Thanks in advance!


Set the correct encoding for the source file - in this case, at this
line at the top of the file: “# coding: iso-8859-1” (without the

If you do it, you will also be able to just use the pound sign
directly, without relying on its code.

Also, non-ASCII characters probably won’t work in cmd window anyway -
you’d have to encode them with whatever encoding cmd uses (you can see
or change it using the chcp command).

– Matma R.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs