更新时间:2022-11-09 10:46:49
怎么样:
# Using pack
puts ["2B71F".hex].pack("U")
# Using chr
puts (0x2B71F).chr(Encoding::UTF_8)
在 Ruby 1.9+ 中你也可以这样做:
In Ruby 1.9+ you can also do:
puts "u{2B71F}"
即u{}
转义序列可用于解码 Unicode 代码点.
I.e. the u{}
escape sequence can be used to decode Unicode codepoints.