ResourceUtils { public static String encode(String str) { String encoded; try { encoded = URLEncoder.encode(str, "UTF-8").replaceAll("%28", "(") .replaceAll("%29", ")") .replaceAll("\\+", "%20") .replaceAll("%27", "'") .replaceAll("%21", "!") .replaceAll("%7E", "~"); } catch (UnsupportedEncodingException e) { throw new MobiException(e); } return encoded; }  static String encode(String str); static String encode(Resource resource); static String decode(String str); static Resource decode(String str, ValueFactory vf);  }
@Test public void encodeTest() throws Exception { String test = ":/#?=& +;\"{[}]@$%^\t"; assertEquals("%3A%2F%23%3F%3D%26%20%2B%3B%22%7B%5B%7D%5D%40%24%25%5E%09", ResourceUtils.encode(test)); }