001    package railo.commons.lang;
002    
003    import java.io.UnsupportedEncodingException;
004    import java.util.BitSet;
005    
006    import org.apache.commons.codec.net.URLCodec;
007    /** 
008     * @deprecated use instead railo.commons.net.URLEncoder
009     * 
010     */
011    public class URLEncoder {
012            
013            private static final BitSet WWW_FORM_URL = new BitSet(256);
014        
015        static {
016            // alpha characters
017            for (int i = 'a'; i <= 'z'; i++) {
018                WWW_FORM_URL.set(i);
019            }
020            for (int i = 'A'; i <= 'Z'; i++) {
021                WWW_FORM_URL.set(i);
022            }
023            // numeric characters
024            for (int i = '0'; i <= '9'; i++) {
025                WWW_FORM_URL.set(i);
026            }
027        }
028    
029    
030            public static String encode(String str, String encoding) throws UnsupportedEncodingException {
031                    return new String(URLCodec.encodeUrl(WWW_FORM_URL, str.getBytes(encoding)),"us-ascii");
032            }
033            
034        
035            
036            public static String encode(String str) throws UnsupportedEncodingException {
037                    return encode(str,"UTF-8");
038            }
039    }