Skip to content

Instantly share code, notes, and snippets.

@10io
Created May 3, 2013 09:03
Show Gist options
  • Save 10io/5508094 to your computer and use it in GitHub Desktop.
Save 10io/5508094 to your computer and use it in GitHub Desktop.
Convert any non ASCII char to their Unicode code point: Héllo -> H\u00e9ello
string.gsub(/[^\x00-\x7F]/) { |non_ascii| "\\u#{"%4.4x" % non_ascii.ord}" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment