Created
May 19, 2015 00:18
-
-
Save eddieantonio/3e3c1c2ca22629299d71 to your computer and use it in GitHub Desktop.
This file contains 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
module U | |
def self.+(obj) | |
codepoint = obj.is_a?(Numeric) ? obj.truncate : obj.to_s.hex | |
to_utf8 codepoint | |
end | |
# Returns a UTF-8 encoded string of the Integer interpreted as a Unicode | |
# code point. | |
def self.to_utf8(integer) | |
# See: http://ruby-doc.org/core-2.2.2/Array.html#pack-method | |
[integer].pack("U") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment