Created
April 11, 2019 12:42
-
-
Save YuukiToriyama/307d268a352e84f765d6c2e1b328c5da to your computer and use it in GitHub Desktop.
コードポイントから文字に起こすメソッド(仮)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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