// Collection of code snippets by Arne VajhÃ¸j 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.net.*;

public class EU {
   public static String myurlencoder(String s) {
      char hexdigit[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
      StringBuffer sb = new StringBuffer("");
      for (int i = 0; i < s.length(); i++) {
         char c = s.charAt(i);
         if (('0' <= c && c <= '9') || ('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z')) {
            sb.append(c);
         } else {
            sb.append('%');
            sb.append(hexdigit[(c >> 4) & 0x0F]);
            sb.append(hexdigit[c & 0x0F]);
         }
      }
      return sb.toString();
   }
   public static void main(String[] args) throws Exception {
      System.out.println(URLEncoder.encode("Dette er ÆØÅ", "ISO-8859-1"));
      System.out.println(myurlencoder("Dette er ÆØÅ"));
      System.out.println(URLEncoder.encode("Dette er ÆØÅ", "ISO-8859-1").replaceAll("\\+", "%20"));
   }
}
