code: public static String encodeUrlPath(String href, String encoding) throws UnsupportedEncodingException {
  		if(href.startsWith("tel:")) return href.replace(' ', '-');
  		int len = href.length();
  		int pos = 0;
  		int stopAt;
  		{
  			int anchorAt = href.lastIndexOf('#');
  			int paramsAt = href.lastIndexOf('?', (anchorAt==-1 ? len : anchorAt) - 1);
  			if(paramsAt == -1) {
  				stopAt = anchorAt == -1 ? len : anchorAt;
  			} else {
  				stopAt = paramsAt;
  			}
  		}
  		StringBuilder SB = new StringBuilder(href.length()*2); // Leave a little room for encoding
  		while(pos < stopAt) {
  			int nextPos = StringUtility.indexOf(href, noEncodeCharacters, pos);
  			if(nextPos == -1) {
  				SB.append(URLEncoder.encode(href.substring(pos, stopAt), encoding));
  				pos = len;
  			} else {
  				if(nextPos > stopAt) nextPos = stopAt;
  				SB.append(URLEncoder.encode(href.substring(pos, nextPos), encoding));
  				if(nextPos < stopAt) {
  					char nextChar = href.charAt(nextPos++);
  					SB.append(nextChar);
  				}
  				pos = nextPos;
  			}
  		}
  		SB.append(href, stopAt, len);
  		return SB.toString();
  	}
docs: Encodes the URL up to trailing '?' or '#' (the first found of the two).
  To avoid ambiguity, parameters and anchors must have been correctly encoded by the caller.
  Does not encode any characters in the set { '?', ':', '/', ';', '#', '+' }.
  
  Encodes tel: (case-sensitive) urls by relacing spaces with hyphens.
  
  @see  #decodeUrlPath(java.lang.String)