package myapp.util;
import java.io.IOException;
public final class UrlUtil {
public static final String ENC_SJIS
= "SJIS"; public static final String ENC_UTF8
= "UTF-8";
private UrlUtil() {
}
return UrlUtil.urlencode(src, UrlUtil.ENC_SJIS);
}
byte[] data = src.getBytes(enc);
int n = data.length;
for (int i = 0; i < n; i++) {
int b = 0xFF & (int)data[i];
if ((b < 0x21) || (b > 0x7E)) {
buf.append('%');
if (b < 0x10) {
buf.append('0');
}
buf.
append(Integer.
toHexString(b
).
toUpperCase()); } else {
char c = (char)b;
switch (c) {
case '_':
case '~':
case '.':
case '-':
buf.append(c);
break;
default:
buf.append('%');
buf.
append(Integer.
toHexString(b
).
toUpperCase()); break;
}
} else {
buf.append(c);
}
}
}
return buf.toString();
}
}
cGFja2FnZSBteWFwcC51dGlsOwoKaW1wb3J0IGphdmEuaW8uSU9FeGNlcHRpb247CgpwdWJsaWMgZmluYWwgY2xhc3MgVXJsVXRpbCB7CiAgICBwdWJsaWMgc3RhdGljIGZpbmFsIFN0cmluZyBFTkNfU0pJUyA9ICJTSklTIjsKCXB1YmxpYyBzdGF0aWMgZmluYWwgU3RyaW5nIEVOQ19VVEY4ID0gIlVURi04IjsKCQoJcHJpdmF0ZSBVcmxVdGlsKCkgewoJfQoJCglwdWJsaWMgc3RhdGljIGZpbmFsIFN0cmluZyB1cmxlbmNvZGUoU3RyaW5nIHNyYykgdGhyb3dzIElPRXhjZXB0aW9uIHsKCQlyZXR1cm4gVXJsVXRpbC51cmxlbmNvZGUoc3JjLCBVcmxVdGlsLkVOQ19TSklTKTsKCX0KCQoJcHVibGljIHN0YXRpYyBmaW5hbCBTdHJpbmcgdXJsZW5jb2RlKFN0cmluZyBzcmMsIFN0cmluZyBlbmMpIHRocm93cyBJT0V4Y2VwdGlvbiB7CgkJYnl0ZVtdIGRhdGEgPSBzcmMuZ2V0Qnl0ZXMoZW5jKTsKCQlpbnQgbiA9IGRhdGEubGVuZ3RoOwoJCVN0cmluZ0J1ZmZlciBidWYgPSBuZXcgU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