remove html characters in blackberry java [closed]
how to remove html characters in a webservice in blackberry java ? (ie remove "$" withString "%24" and "&" withString "%26" and so on..)
You would use one of the many freely-available URL encoders. Search for "blackberry url encoder" or "java me url encoder" or something similar. For example, here's one and here's another.
It's always been a mystery to me why URL encoding and decoding was not included in either MIDP or the BlackBerry API given that it's so useful.
String s="http://199.199.199.199/webservices/login.php";
int b = (int)s.charAt(i++);
if ((b>=0x30 && b<=0x39) || (b>=0x41 && b<=0x5A) || (b>=0x61 && b<=0x7A)) {
tmp.append((char)b);
}
else {
tmp.append("%");
if (b <= 0xf) tmp.append("0");
tmp.append(Integer.toHexString(b));
}
Dialog.alert(tmp.toString());
}
精彩评论