📄 urldecoder.java
字号:
// Decompiled by DJ v3.5.5.77 Copyright 2003 Atanas Neshkov Date: 2003-6-23 10:56:27
// Home Page : http://members.fortunecity.com/neshkov/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: URLDecoder.java
package com.struts2.framework.util;
import java.io.UnsupportedEncodingException;
// Referenced classes of package org.fat32.util.net:
// URLEncoder
public class URLDecoder {
/**
* @deprecated Method decode is deprecated
*/
public static String decode(String s) {
String str = null;
try {
str = decode(s, dfltEncName);
} catch (UnsupportedEncodingException unsupportedencodingexception) {
}
return str;
}
public static String decode(String s, String enc)
throws UnsupportedEncodingException {
boolean needToChange = false;
StringBuffer sb = new StringBuffer();
int numChars = s.length();
int i = 0;
if (enc.length() == 0)
throw new UnsupportedEncodingException(
"URLDecoder: empty string enc parameter");
while (i < numChars) {
char c = s.charAt(i);
switch (c) {
case 43: // '+'
sb.append(' ');
i++;
needToChange = true;
break;
case 37: // '%'
try {
byte bytes[] = new byte[(numChars - i) / 3];
int pos = 0;
while (i + 2 < numChars && c == '%') {
bytes[pos++] = (byte) Integer.parseInt(s.substring(
i + 1, i + 3), 16);
if ((i += 3) < numChars)
c = s.charAt(i);
}
if (i < numChars && c == '%')
throw new IllegalArgumentException(
"URLDecoder: Incomplete trailing escape (%) pattern");
sb.append(new String(bytes, 0, pos, enc));
} catch (NumberFormatException e) {
throw new IllegalArgumentException(
"URLDecoder: Illegal hex characters in escape (%) pattern - "
+ e.getMessage());
}
needToChange = true;
break;
case 38: // '&'
case 39: // '\''
case 40: // '('
case 41: // ')'
case 42: // '*'
default:
sb.append(c);
i++;
break;
}
}
return needToChange ? sb.toString() : s;
}
public URLDecoder() {
}
static String dfltEncName;
static {
dfltEncName = URLEncoder.dfltEncName;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -