Vincent Jia
Vincent Jia

Reputation: 612

How to treat/understand some strange signs in string in Java, like %2B, %5E20?

I debugged the existing project and got a string variable:

"q=%2B%28%28%28keywords_en%3A%28pp%3F+OR+pp%29%29%29%29+%28+name%3A%28pp%3F%29%5E20+number%3A%28pp%3F%29%5E20+creator%3A%28OR%5C%3Art.org.WuoUser%5C%3A11%29%5E2+modifier%3A%28OR%5C%3Art.org.WuoUser%5C%3A11%29%5E2+%29+_val_%3A%22recip%28rord%28modifyTimestamp%29%2C1%2C1000%2C1000%29%22%5E2";

I am a little confused what these "%2B, %28, %3A, %5E, %5E20" stand for? If they're some escape character, how can I get the corresponding human-readable letters? It would be very appreciated if anyone can give some help. Thanks in advance.

Upvotes: 1

Views: 291

Answers (1)

Ted Hopp
Ted Hopp

Reputation: 234847

You can decode it using:

String decodedString = URLDecoder.decode(encodedString, "UTF-8");

(or whatever character encoding is appropriate if not UTF-8).

Upvotes: 4

Related Questions