| #!/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