Home > Archive > Java Help > January 2006 > Need help with decoding URL
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Need help with decoding URL
|
|
|
| I have an encoded string which I need to decode to present to the user.
The string is:
S1 = "php%253Fcmp";
I want to display
php?cmp
to the user. I have tried creating a URI object from this class, then
using getPath() from the object, but that gives me this output:
php%3Fcmp
I get the same output when I URLDecoder.decode to convert the string.
How do I get the correct format? Thanks for any help.
| |
|
| On Fri, 20 Jan 2006 09:27:04 +1100, Ray wrote:
> I have an encoded string which I need to decode to present to the user.
> The string is:
>
> S1 = "php%253Fcmp";
This is encoded twice. The "%" character has been (correctly) encoded as
"%25"
> I want to display
>
> php?cmp
>
> to the user. I have tried creating a URI object from this class, then
> using getPath() from the object, but that gives me this output:
>
> php%3Fcmp
>
> I get the same output when I URLDecoder.decode to convert the string.
> How do I get the correct format? Thanks for any help.
You'd need to decode twice because of the above.
First run you'll get php%3Fcmp and 2nd run you'll get php?cmp
--
Sean
"It is one of the essential features of [incompetence] that the person
so afflicted is incapable of knowing that he is incompetent. To have
such knowledge would already be to remedy a good portion of the
offense." --W.I. Miller
| |
| Oliver Wong 2006-01-24, 7:06 pm |
|
"SMC" <smc@nospam.org> wrote in message
news:pan.2006.01.19.22.40.00.409436.32650@nospam.org...
> On Fri, 20 Jan 2006 09:27:04 +1100, Ray wrote:
>
>
> This is encoded twice. The "%" character has been (correctly) encoded as
> "%25"
>
>
> You'd need to decode twice because of the above.
>
> First run you'll get php%3Fcmp and 2nd run you'll get php?cmp
If the double-encoding is unintentional, you probably have a bug
elsewhere as well, causing the double encoding, that you should address.
- Oliver
|
|
|
|
|