How about:
# Using pack
puts ["2B71F".hex].pack("U")
# Using chr
puts (0x2B71F).chr(Encoding::UTF_8)
In Ruby 1.9+ you can also do:
puts "\u{2B71F}"
I.e. the \u{}
escape sequence can be used to decode Unicode codepoints.
More Related Contents:
- Ruby 1.9: how can I properly upcase & downcase multibyte strings?
- Very Basic Ruby puts and gets
- Ruby: String Comparison Issues
- Why use symbols as hash keys in Ruby?
- ruby 1.9: invalid byte sequence in UTF-8
- What does %w(array) mean?
- How to convert a UTF-8 string into Unicode?
- How do I remove emoji from string
- What’s the difference between a string and a symbol in Ruby?
- How to check whether a string contains a substring in Ruby
- Why is the shovel operator (
- What is the easiest way to remove the first character from a string?
- Backslashes in single quoted strings vs. double quoted strings
- Ruby 1.9 Array.to_s behaves differently?
- Extract a substring from a string in Ruby using a regular expression
- How to get rid of non-ascii characters in ruby
- Which style of Ruby string quoting do you favour?
- Nokogiri, open-uri, and Unicode Characters
- String interpolation in Ruby doesn’t work?
- How to avoid tripping over UTF-8 BOM when reading files
- Measure the distance between two strings with Ruby?
- Read binary file as string in Ruby
- to_s vs. to_str (and to_i/to_a/to_h vs. to_int/to_ary/to_hash) in Ruby
- Ruby: Merging variables in to a string
- Split string by multiple delimiters
- What is the use case for Ruby’s %q / %Q quoting methods?
- What is the opposite of string.next?
- What is the best way to split a string to get all the substrings by Ruby?
- How to determine if a character is a Chinese character
- Is this the best way to unescape unicode escape sequences in Ruby?