code: def _escape_string(text, _map={}):
      
      if isinstance(text, str):
          text = text.encode('ascii')
      assert isinstance(text, (bytes, bytearray))
  
      if not _map:
          for ch in range(256):
              if ch in _VALID_CHARS:
                  _map[ch] = chr(ch)
              else:
                  _map[ch] = '\\%02x' % ch
              if six.PY2:
                  _map[chr(ch)] = _map[ch]
  
      buf = [_map[ch] for ch in text]
      return ''.join(buf)
docs: Escape the given bytestring for safe use as a LLVM array constant.