Re: Need help with decoding URL



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
.



Relevant Pages

  • Re: TLV Objekte aus Datei lesen
    ... Weil STRING als OCTET STRING und IA5STRING vorkommen, das aber piepegal ist, schere ich die alle über einen Kamm und komme mit meinem STRING aus. ... Es gibt hier keinen Len-Parameter beim Decode. ... In meinen Daten haben die meisten der Arrays eine ein- oder zweibyteige Angabe der Anzahl der Records am Anfang. ... technischen Daten der Karte sofern sie in der Datei stehn). ...
    (de.comp.lang.delphi.misc)
  • Re: Sending floats over a client-server in Smalltalk
    ... The trick is knowing what to decode them ... Then encode the number in the remaining bytes. ... ByteString>>floatAt: byteIndex ... I could then take a string ...
    (comp.lang.smalltalk)
  • Re: [Full-Disclosure] Phishing scam - Obfuscated url help please
    ... > Let's decode a URL that may end up making IE destroying the PC or ... just to trick some clueless newbie or "typical user" but to outwit ... string variable and writes that to a file). ... output file with a "safe" file viewer. ...
    (Full-Disclosure)
  • Re: UnicodeDecodeError: utf-8 codec cant decode byte 0xb6 in position 0: invalid start byte
    ... Don't fix the problem till you understand it. ... Figure out who is dealing with a byte string here, and where that byte string came from. ... Adding a decode, especially one that's going to do the same decode as your original error message, is very premature. ... I'll bet the real problem is you're using some greek characters in the name of the environment variable, rather than "REMOTE_HOST" So everything you show us is laboriously retyped, hiding the real problems underneath. ...
    (comp.lang.python)
  • Re: Selecting a record froma table where a column might be null
    ... In perl dbi, ... So you use the decode function in your ... string null in decode you can ... Win a $20,000 Career Makeover at Yahoo! ...
    (perl.dbi.users)