Create a gist now

Instantly share code, notes, and snippets.

anonymous /gist:e66a11ccac7b4e4da9f6
Created Mar 10, 2015

What would you like to do?
#!/usr/bin/env ruby
special_chars = Hash[%w[<< >>]
.map{ |c| [c, c.unpack('a1a1')
.flat_map{ |n| n.unpack('H*') }
.join('-').upcase]}]
.merge(Hash[%w[* & + - ! ?]
.map{|c| [c, c.unpack('H*')[0].upcase]}])
output #=> {"<<"=>"3C-3C", ">>"=>"3E-3E", "*"=>"2A", "&"=>"26", "+"=>"2B", "-"=>"2D", "!"=>"21", "?"=>"3F"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment