    private String escapeURL(String base) {
	final char[] chs = base.toCharArray();
	final StringBuffer result = new StringBuffer();
	final int length = chs.length;
        for (int i = 0; i < length; i++) {
	    final char ch = chs[i];
	    if (ch <= 0x20) {
		result.append('%').append(makeHHString(ch));
	    } 
	    else if (ch > '\u007F') {
		result.append('%')
		      .append(makeHHString((ch >> 6) | 0xC0))
		      .append('%')
		      .append(makeHHString((ch & 0x3F) | 0x80));
	    }
	    else {
	        switch (ch) {
		    case '\u007F' :
		    case '\u007B' :
		    case '\u007D' :
		    case '\u007C' :
		    case '\\'     :
		    case '\t'     :
		    case '\u005E' :
		    case '\u007E' :
		    case '\u005B' :
		    case '\u005D' :
		    case '\u0060' :
		    case '\u0020' :
		        result.append('%')
		              .append(Integer.toHexString((int) ch));
		        break;
		    case '"':
			result.append("&quot;");
			break;
		    default:	
		        result.append(ch); 
			break;
	        }
	    } 
  	}
	return result.toString();
    }

    private String escapeURL(String base) {
	final char[] chs = base.toCharArray();
	final StringBuffer result = new StringBuffer();
	final int length = chs.length;
        for (int i = 0; i < length; i++) {
	    final char ch = chs[i];
	    if (ch <= 0x20) {
		result.append('%').append(makeHHString(ch));
	    } 
	    else if (ch > '\u007F') {
		result.append('%')
		      .append(makeHHString((ch >> 6) | 0xC0))
		      .append('%')
		      .append(makeHHString((ch & 0x3F) | 0x80));
	    }
	    else {
	        switch (ch) {
		    case '\u007F' :
		    case '\u007B' :
		    case '\u007D' :
		    case '\u007C' :
		    case '\\'     :
		    case '\t'     :
		    case '\u005E' :
		    case '\u007E' :
		    case '\u005B' :
		    case '\u005D' :
		    case '\u0060' :
		    case '\u0020' :
		        result.append('%')
		              .append(Integer.toHexString((int) ch));
		        break;
		    case '"':
			result.append("%22");
			break;
		    default:	
		        result.append(ch); 
			break;
	        }
	    } 
  	}
	return result.toString();
    }
