code: def string(s):
      
      ret = ['"']
      for c in s:
          if ' ' <= c < '\x7f':
              if c == "'" or c == '"' or c == '\\':
                  ret.append('\\')
              ret.append(c)
              continue
          elif c <= '\x7f':
              if c in ('\r', '\n', '\t'):
                  # unicode-escape produces bytes
                  ret.append(c.encode('unicode-escape').decode("ascii"))
                  continue
          i = ord(c)
          ret.append('\\u')
          ret.append('%x' % (i >> 12))
          ret.append('%x' % ((i >> 8) & 0x0f))
          ret.append('%x' % ((i >> 4) & 0x0f))
          ret.append('%x' % (i & 0x0f))
      ret.append('"')
      return ''.join(ret)
docs: Convert a string to a escaped ASCII representation including quotation marks
      :param s: a string
      :return: ASCII escaped string