code: static String quoteForCommandString(String s) {
      StringBuilder quoted = new StringBuilder().append('"');
      for (int i = 0; i < s.length(); i++) {
        int cp = s.codePointAt(i);
        if (cp == '"' || cp == '\\') {
          quoted.appendCodePoint('\\');
        }
        quoted.appendCodePoint(cp);
      }
      return quoted.append('"').toString();
    }
docs: Quotes a string so that it can be used in a command string.
  Basically, just add simple escapes. E.g.:
  original single argument : ab "cd" ef
  after: "ab \"cd\" ef"
  
  This can be parsed back into a single argument by python's "shlex.split()" function.