'How to print unicode character U-1F4A9 'pile of poo' emoji
I am trying to print a unicode character in Ruby, specifically the pile of poo. It has a unicode value of U-1F4A9. But when I try to print "\u1F4A9" to the output or a file, I see nothing.
Do I need to print to a specific type of file to see the pile of poo? If so, what type of file? Is there any way to print this to the common output? (I'm using Rubymine)
Solution 1:[1]
Unicode code points with more than four hex digits must be enclosed in curly braces:
puts "\u{1f4a9}"
# => ?
This is pretty poorly documented, so don't feel bad about not figuring it out. A nice thing about the curly brace syntax is that you can embed multiple code points separated by spaces:
puts "\u{1f4a9 1f60e}"
# => ??
Of course, since Ruby 2.0, UTF-8 has been the default encoding, so you can always just put the emoji directly into your source:
puts "?"
# => ?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |