class 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;
    }

}