Skip to content

Instantly share code, notes, and snippets.

@YuukiToriyama
Created April 11, 2019 12:42
Show Gist options
  • Save YuukiToriyama/307d268a352e84f765d6c2e1b328c5da to your computer and use it in GitHub Desktop.
Save YuukiToriyama/307d268a352e84f765d6c2e1b328c5da to your computer and use it in GitHub Desktop.
コードポイントから文字に起こすメソッド(仮)
#!/usr/bin/ruby
# 16進形式のUnicodeコードポイントをキャラクタに変換します
class String
def to_char()
self.to_i(16).chr("UTF-8")
end
end
# example「漢」
str = "U+6F22"
str.upcase =~ /U\+([0-9A-F]*)/
puts $1.to_char
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment