dirkv 01/08/13 10:05:47
Modified: org/apache/commons/httpclient/URLUtil.java
Log:
replace depricated method
FIXME: replace byte[] with char[] in encode and decode methods
public final class URLUtil {
@@ -165,18 +165,27 @@
* @exception IllegalArgumentException if a '%' character is not
followed
* by a valid 2-digit hexadecimal number
*/
- public static String URLDecode(String str, String enc) {
-
- if (str == null)
- return (null);
-
- int len = str.length();
- byte[] bytes = new byte[len];
- str.getBytes(0, len, bytes, 0);
-
- return URLDecode(bytes, enc);
-
- }
+ public static String URLDecode(String str, String enc) {
+
+ if (str == null)
+ return (null);
+
+ // FIXME: replace all byte[] by char[]
+ byte[] bytes;
+ if (enc==null) {
+ bytes=str.getBytes();
+ }
+ else {
+ try {
+ bytes=str.getBytes(enc);
+ }
+ catch (UnsupportedEncodingException ex) {
+ bytes=str.getBytes();
+ }
+ }
+
+ return URLDecode(bytes, enc);
+ }