X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fibex%2Futil%2FFileNameEncoder.java;fp=src%2Forg%2Fibex%2Futil%2FFileNameEncoder.java;h=0000000000000000000000000000000000000000;hb=ac84b5a03467c0853c7275105712ece6c71be1f1;hp=e68bba208d98ba8ccccd2aee2bd9365c53bc6c81;hpb=3f8aa5300e178e8975b0edc896a5a9d303e7bdf3;p=org.ibex.core.git diff --git a/src/org/ibex/util/FileNameEncoder.java b/src/org/ibex/util/FileNameEncoder.java deleted file mode 100644 index e68bba2..0000000 --- a/src/org/ibex/util/FileNameEncoder.java +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2003 Adam Megacz all rights reserved. -// -// You may modify, copy, and redistribute this code under the terms of -// the GNU Library Public License version 2.1, with the exception of -// the portion of clause 6a after the semicolon (aka the "obnoxious -// relink clause") - -package org.ibex.util; -import java.util.*; -import java.io.*; - -/** provides commands to urlencode and urldecode strings, making sure - * to escape sequences which have special meanings in filenames */ -public class FileNameEncoder { - - private static final char[] hex = - new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; - - public static String encode(String s) { - StringBuffer sb = new StringBuffer(); - try { - byte[] b = s.getBytes("UTF-8"); - for(int i=0; i 126 || c == '%' || (i == 0 && c == '.')) - sb.append("%" + hex[(b[i] & 0xf0) >> 8] + hex[b[i] & 0xf]); - else sb.append(c); - } - return sb.toString(); - } catch (UnsupportedEncodingException uee) { - throw new Error("this should never happen; Java spec mandates UTF-8 support"); - } - } - - public static String decode(String s) { - StringBuffer sb = new StringBuffer(); - byte[] b = new byte[s.length() * 2]; - int bytes = 0; - for(int i=0; i