common/src/main/java/HTTPClient/Util.java
/**
     * Replace given characters by their quoted version. Quoted characters
     * are characters preceded by a slash. E.g. "c" would be replaced by "\c".
     * This is used in generating http headers where certain characters need
     * to be quoted, such as the quote character &lt;"&gt;.
     *
     * @param str   the string do quote
     * @param qlist the list of characters to quote
     * @return the string do with all characters replaced by their
     *         quoted version.
     */
Replace given characters by their quoted version. Quoted characters
are characters preceded by a slash.

@param str   the string do quote
@param qlist the list of characters to quote
@return the string do with all characters replaced by their
quoted version.
Replace given characters by their quoted version . Quoted characters are characters preceded by a slash . @param str the string do quote @param qlist the list of characters to quote @return the string do with all characters replaced by their quoted version .
public final static String quoteString(String str, String qlist)
    {
	char[] list = qlist.toCharArray();
	int idx;
	for (idx=0; idx<list.length; idx++)
	    if (str.indexOf(list[idx]) != -1)  break;
	if (idx == list.length)  return str;
	int len = str.length();
	char[] buf = new char[len*2];
	str.getChars(0, len, buf, 0);
	int pos = 0;
	while (pos < len)
	{
	    if (qlist.indexOf(buf[pos], 0) != -1)
	    {
		if (len == buf.length)
		    buf = Util.resizeArray(buf, len+str.length());
		System.arraycopy(buf, pos, buf, pos+1, len-pos);
		len++;
		buf[pos++] = '\\';
	    }
	    pos++;
	}
	return new String(buf, 0, len);
    }
public final static String quoteString ( String str , String qlist ) { char [ ] list = qlist . toCharArray ( ) ; int idx ; for ( idx = 0 ; idx < list . length ; idx ++ ) if ( str . indexOf ( list [ idx ] ) != - 1 ) break ; if ( idx == list . length ) return str ; int len = str . length ( ) ; char [ ] buf = new char [ len * 2 ] ; str . getChars ( 0 , len , buf , 0 ) ; int pos = 0 ; while ( pos < len ) { if ( qlist . indexOf ( buf [ pos ] , 0 ) != - 1 ) { if ( len == buf . length ) buf = Util . resizeArray ( buf , len + str . length ( ) ) ; System . arraycopy ( buf , pos , buf , pos + 1 , len - pos ) ; len ++ ; buf [ pos ++ ] = '\\' ; } pos ++ ; } return new String ( buf , 0 , len ) ; }
Replace given characters by their quoted version.
Replace given characters by their quoted version .