Created
June 25, 2014 02:27
-
-
Save koichiro/2efb70d683c09336a488 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
# "\x34AC23" | |
def hex2bin s | |
s = s[2, s.length] | |
raise "Not a valid hex string" unless(s =~ /^[\da-fA-F]+$/) | |
r = s.scan(/../).map{ |b| b.to_i(16) }.pack('C*') | |
r.force_encoding("UTF-8") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment