code: public static String encodeString(String value) {
      if (value == null) {
        return null;
      }
      StringBuilder encoded = new StringBuilder();
      int len = value.length();
      for (int i = 0; i < len; i++) {
        char c = value.charAt(i);
        switch (c) {
          case ARRAY_DELIMITER_CHAR:
          case KEY_VALUE_DELIMITER_CHAR:
          case ESCAPE_CHAR:
            encoded.append(ESCAPE_CHAR);
            break;
          default:
            // just append char
        }
        encoded.append(c);
      }
      return encoded.toString();
    }
docs: Escape all delimiter chars in string.
  @param value String
  @return Encoded string