001    /**
002     * Implements the Cold Fusion Function urldecode
003     */
004    package railo.runtime.functions.other;
005    
006    import java.io.UnsupportedEncodingException;
007    
008    import railo.commons.net.URLDecoder;
009    import railo.runtime.PageContext;
010    import railo.runtime.exp.ExpressionException;
011    import railo.runtime.ext.function.Function;
012    
013    public final class URLDecode implements Function {
014            public static String call(PageContext pc , String str) throws ExpressionException {
015                    return call(pc,str,"utf-8");
016            }
017            public static String call(PageContext pc , String str, String encoding) throws ExpressionException {
018                    try {
019                            return java.net.URLDecoder.decode(str,encoding);
020                    } catch (Throwable t) {
021                            try {
022                                    return URLDecoder.decode(str,encoding,true);
023                            } catch (UnsupportedEncodingException uee) {
024                                    throw new ExpressionException(uee.getMessage());
025                            }
026                    }
027                    /*try {
028                            return URLDecoder.decode(str,encoding);
029                    } catch (UnsupportedEncodingException e) {
030                            throw new ExpressionException(e.getMessage());
031                    }*/
032            }
033    }