Displaying Unicode Characters in Ruby

By rainkinz on Mar 15, 2012, comments 52

If you know the Unicode character code and want to decode it you can do something like this:

  • Ruby 1.8
puts ["2665".hex].pack("U")
♥
=> nil
  • Ruby 1.9 In Ruby 1.9 the \u{} escape sequence can be used to decode unicode codepoints:
puts "\u{2665}"
♥
=> nil
5785
Cfdae901e067df0956e6d35c6fa706b4.png?s=48&d=http%3a%2f%2fkuripai.com%2fassets%2fguest Mami on Sep 11, 2015 at 7:26 PM

2012/07/06 - 下午 2:54 5F Sweden Opera Mini 7.60 Windows Server 2003A new basic on the net search on a term FICO as well as criedt scores

5831
A6478799d355cc2abe0c2d2f4ad09dd4.png?s=48&d=http%3a%2f%2fkuripai.com%2fassets%2fguest Krishna on Oct 22, 2015 at 1:40 AM

Hi Carrie!We don't typically buy in other saetts, the travel time and cost plus shipping it back is just too high. Good luck selling and if you are ever in Arizona, please look us up!

5944
8fcbf39e6947a3281597a71c54332fe1.png?s=48&d=http%3a%2f%2fkuripai.com%2fassets%2fguest Deandre on Jan 06, 2016 at 7:50 PM

Time to face the music armed with this great inafomrtion.

5946
8fcbf39e6947a3281597a71c54332fe1.png?s=48&d=http%3a%2f%2fkuripai.com%2fassets%2fguest Deandre on Jan 06, 2016 at 7:52 PM

Time to face the music armed with this great inafomrtion.

5947
8fcbf39e6947a3281597a71c54332fe1.png?s=48&d=http%3a%2f%2fkuripai.com%2fassets%2fguest Deandre on Jan 06, 2016 at 7:53 PM

Time to face the music armed with this great inafomrtion.

Comment: