Skip to content

Instantly share code, notes, and snippets.

@tomasmuller
Created February 6, 2012 11:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomasmuller/1751630 to your computer and use it in GitHub Desktop.
Save tomasmuller/1751630 to your computer and use it in GitHub Desktop.
Ruby String to Hexadecimal
s = "Tomás Augusto Müller"
# Hex Array
#
s.unpack('U' * s.length).collect { |x| x.to_s(16) }
# Hex String
#
s.unpack('U' * s.length).collect { |x| x.to_s(16) }.join
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment