Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/extensions/string.rb

Instance Method Summary collapse

Instance Method Details

#with_unescaped_unicode_esque_sequencesObject

Example: “coffee: 9749” for “coffee: ☕”



3
4
5
6
7
# File 'lib/extensions/string.rb', line 3

def with_unescaped_unicode_esque_sequences
  self.force_encoding('UTF-8').gsub(/\\(\d+)/) { |m|
    [$1.to_i.to_s(16).rjust(4, '0')].pack("H*").unpack("n*").pack("U*")
  }
end