class RuboCop::StringInterpreter

For example, ā€œ\nā€ will be converted to ā€œnā€.
interpreter would when reading a double-quoted string literal.
Take a string with embedded escapes, and convert the escapes as the Ruby

def interpret(string)

def interpret(string)
  # We currently don't handle \cx, \C-x, and \M-x
  string.gsub(STRING_ESCAPE_REGEX) do |escape|
    STRING_ESCAPES[escape] || interpret_string_escape(escape)
  end
end

def interpret_hex(escape)

def interpret_hex(escape)
  [escape[2..].hex].pack('C')
end

def interpret_octal(escape)

def interpret_octal(escape)
  [escape[1..].to_i(8)].pack('C')
end

def interpret_string_escape(escape)

def interpret_string_escape(escape)
  case escape[1]
  when 'u'  then interpret_unicode(escape)
  when 'x'  then interpret_hex(escape)
  when /\d/ then interpret_octal(escape)
  else
    escape[1] # literal escaped char, like \\
  end
end

def interpret_unicode(escape)

def interpret_unicode(escape)
  if escape[2] == '{'
    escape[3..].split(/\s+/).map(&:hex).pack('U*')
  else
    [escape[2..].hex].pack('U')
  end
end