s84 s84 - 1 year ago 150
Ruby Question

Convert unicode codepoint to string character in Ruby

I have these values from a unicode database but I'm not sure how to translate them into the human readable form. What are these even called?

Here they are:

  • U+2B71F

  • U+2A52D

  • U+2A68F

  • U+2A690

  • U+2B72F

  • U+2B4F7

  • U+2B72B

How can I convert these to there readable symbols?

Answer Source

How about:

puts ["2B71F".hex].pack("U")


In Ruby 1.9 you can even do this:

puts "\u{2B71F}"

I.e. the \u{} escape sequence can be used to decode Unicode codepoints.