static StringBuilder appendQuotedString(StringBuilder target,String key){
  target.append('"');
  for (int i=0, len=key.length(); i < len; i++) {
    char ch=key.charAt(i);
switch (ch) {
case '\n':
      target.append("%0A");
    break;
case '\r':
  target.append("%0D");
break;
case '"':
target.append("%22");
break;
default :
target.append(ch);
break;
}
}
target.append('"');
return target;
}

static StringBuilder appendQuotedString ( StringBuilder target , String key ) { target . append ( '"' ) ; for ( int i = 0 , len = key . length ( ) ; i < len ; i ++ ) { char ch = key . charAt ( i ) ; switch ( ch ) { case '\n' : target . append ( "%0A" ) ; break ; case '\r' : target . append ( "%0D" ) ; break ; case '"' : target . append ( "%22" ) ; break ; default : target . append ( ch ) ; break ; } } target . append ( '"' ) ; return target ; }
appends a quoted - string to a stringbuilder . < p > rfc 2388 is rather vague about how one should escape special characters in form - data parameters , and as it turns out firefox and chrome actually do rather different things , and both say in their comments that they ' re not really sure what the right approach is . we go with chrome ' s behavior ( which also experimentally seems to match what ie does ) , but if you actually want to have a good chance of things working , please avoid double - quotes , newlines , percent signs , and the like in your field names .
