JC man
JC man

Reputation: 103

URLDecode cannot decode this case property

Hello developers:

I try to decode this chinese url

%ACP%BB%DA%A4j%BE%D4


by using " java.net.URLDecoder " to decode with

big5


but, the result is

�P際�j戰


apparently, that is not correct. The correct result is

星際大戰

can anyone tell me how to decode this url to get correct result ?
Thanks for your help, and Happy New Year ! !

Upvotes: 0

Views: 220

Answers (1)

JC man
JC man

Reputation: 103

I got the answer.
1. Java take "%" as escape character with decoding string.
2. Java process character with 2 bytes.

So, my final solution is:

case: %ACP
step:
1. split out 3rd character: %AC "P"
2. transform "P" from decimal to hexadecimal value. "P" with decimal value: 80 to %50.
3. recombine "%AC", "%50" to "%AC%50".
4. URLDecoder.decode("%AC%50", "big5"), then return "星".

Upvotes: -1

Related Questions