Skip to content

Instantly share code, notes, and snippets.

@saimonmoore
Created February 24, 2012 14:48
Show Gist options
  • Save saimonmoore/1901405 to your computer and use it in GitHub Desktop.
Save saimonmoore/1901405 to your computer and use it in GitHub Desktop.
Unescape double escaped hex encoded ASCII-8Bit and convert to UTF-8
puts "afasgfdsfbuz\\xC3\\xB3n".gsub(/\\x([A-F0-9][A-F0-9])/) {|h| [$1.hex].pack("C*")}.force_encoding('UTF-8')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment