Decode URL string

Discussion in 'ASP .Net' started by Snedker, Sep 1, 2008.

  1. Snedker

    Snedker Guest

    As part of URL I have ie:

    www.website.com?test=%F8%E5%C6%D8%C5

    Requesting the querystring and displaying the content on web I just
    get a bunch of squares instead of the special Danish characters that I
    expect. But I don't know how to decode them properly. Do you?

    Any help or pointer in the right direction is greatly appreciated -
    thanks in advance!


    Kind regards /Snedker
     
    Snedker, Sep 1, 2008
    #1
    1. Advertising

  2. Snedker wrote:
    > As part of URL I have ie:
    >
    > www.website.com?test=%F8%E5%C6%D8%C5
    >
    > Requesting the querystring and displaying the content on web I just
    > get a bunch of squares instead of the special Danish characters that I
    > expect. But I don't know how to decode them properly. Do you?
    >
    > Any help or pointer in the right direction is greatly appreciated -
    > thanks in advance!
    >
    >
    > Kind regards /Snedker


    How are you trying to decode them?
     
    Florian Paulus, Sep 1, 2008
    #2
    1. Advertising

  3. Snedker

    Snedker Guest

    On 1 Sep., 14:14, Florian Paulus <> wrote:
    > Snedker wrote:
    > > As part of URL I have ie:

    >
    > >www.website.com?test=%F8%E5%C6%D8%C5

    >
    > > Requesting the querystring and displaying the content on web I just
    > > get a bunch of squares instead of the special Danish characters that I
    > > expect. But I don't know how to decode them properly. Do you?

    >
    > > Any help or pointer in the right direction is greatly appreciated -
    > > thanks in advance!

    >
    > > Kind regards /Snedker

    >
    > How are you trying to decode them?


    Using System.Web.SystemHttpUtility.UrlDecode is what I've tried, but
    not with the result of "squares"...

    Regards /Snedker
     
    Snedker, Sep 1, 2008
    #3
  4. Snedker

    Snedker Guest

    On 1 Sep., 14:32, Snedker <> wrote:
    > On 1 Sep., 14:14, Florian Paulus <> wrote:
    >
    > > Snedker wrote:
    > > > As part of URL I have ie:

    >
    > > >www.website.com?test=%F8%E5%C6%D8%C5

    >
    > > > Requesting the querystring and displaying the content on web I just
    > > > get a bunch of squares instead of the special Danish characters that I
    > > > expect. But I don't know how to decode them properly. Do you?

    >
    > > > Any help or pointer in the right direction is greatly appreciated -
    > > > thanks in advance!

    >
    > > > Kind regards /Snedker

    >
    > > How are you trying to decode them?

    >
    > Using System.Web.SystemHttpUtility.UrlDecode is what I've tried, but
    > not with the result of "squares"...
    >
    > Regards /Snedker


    ...but WITH the result of squares, that is... :)
    /snedker
     
    Snedker, Sep 1, 2008
    #4
  5. Snedker wrote:
    > On 1 Sep., 14:32, Snedker <> wrote:
    >> On 1 Sep., 14:14, Florian Paulus <> wrote:
    >>
    >>> Snedker wrote:
    >>>> As part of URL I have ie:
    >>>> www.website.com?test=%F8%E5%C6%D8%C5
    >>>> Requesting the querystring and displaying the content on web I just
    >>>> get a bunch of squares instead of the special Danish characters that I
    >>>> expect. But I don't know how to decode them properly. Do you?
    >>>> Any help or pointer in the right direction is greatly appreciated -
    >>>> thanks in advance!
    >>>> Kind regards /Snedker
    >>> How are you trying to decode them?

    >> Using System.Web.SystemHttpUtility.UrlDecode is what I've tried, but
    >> not with the result of "squares"...
    >>
    >> Regards /Snedker

    >
    > ..but WITH the result of squares, that is... :)
    > /snedker

    Did you try to set the default encodings to utf-8 in your web.config?

    <configuration>
    <system.web>
    <globalization
    requestEncoding="utf-8"
    responseEncoding="utf-8" />
    </system.web>
    </configuration>
     
    Florian Paulus, Sep 1, 2008
    #5
  6. Snedker

    Snedker Guest

    On 1 Sep., 14:54, Florian Paulus <> wrote:
    > Snedker wrote:
    > > On 1 Sep., 14:32, Snedker <> wrote:
    > >> On 1 Sep., 14:14, Florian Paulus <> wrote:

    >
    > >>> Snedker wrote:
    > >>>> As part of URL I have ie:
    > >>>>www.website.com?test=%F8%E5%C6%D8%C5
    > >>>> Requesting the querystring and displaying the content on web I just
    > >>>> get a bunch of squares instead of the special Danish characters that I
    > >>>> expect. But I don't know how to decode them properly. Do you?
    > >>>> Any help or pointer in the right direction is greatly appreciated -
    > >>>> thanks in advance!
    > >>>> Kind regards /Snedker
    > >>> How are you trying to decode them?
    > >> Using System.Web.SystemHttpUtility.UrlDecode is what I've tried, but
    > >> not with the result of "squares"...

    >
    > >> Regards /Snedker

    >
    > > ..but WITH the result of squares, that is... :)
    > > /snedker

    >
    > Did you try to set the default encodings to utf-8 in your web.config?
    >
    > <configuration>
    >     <system.web>
    >        <globalization
    >           requestEncoding="utf-8"
    >           responseEncoding="utf-8" />
    >     </system.web>
    > </configuration>- Skjul tekst i anførselstegn -
    >
    > - Vis tekst i anførselstegn -


    Those exact settings are already set.

    Thx for input and efforts!

    Regards /Snedker
     
    Snedker, Sep 1, 2008
    #6
  7. Snedker

    Snedker Guest

    On 1 Sep., 15:38, Snedker <> wrote:
    > On 1 Sep., 14:54, Florian Paulus <> wrote:
    >
    >
    >
    >
    >
    > > Snedker wrote:
    > > > On 1 Sep., 14:32, Snedker <> wrote:
    > > >> On 1 Sep., 14:14, Florian Paulus <> wrote:

    >
    > > >>> Snedker wrote:
    > > >>>> As part of URL I have ie:
    > > >>>>www.website.com?test=%F8%E5%C6%D8%C5
    > > >>>> Requesting the querystring and displaying the content on web I just
    > > >>>> get a bunch of squares instead of the special Danish characters that I
    > > >>>> expect. But I don't know how to decode them properly. Do you?
    > > >>>> Any help or pointer in the right direction is greatly appreciated -
    > > >>>> thanks in advance!
    > > >>>> Kind regards /Snedker
    > > >>> How are you trying to decode them?
    > > >> Using System.Web.SystemHttpUtility.UrlDecode is what I've tried, but
    > > >> not with the result of "squares"...

    >
    > > >> Regards /Snedker

    >
    > > > ..but WITH the result of squares, that is... :)
    > > > /snedker

    >
    > > Did you try to set the default encodings to utf-8 in your web.config?

    >
    > > <configuration>
    > >     <system.web>
    > >        <globalization
    > >           requestEncoding="utf-8"
    > >           responseEncoding="utf-8" />
    > >     </system.web>
    > > </configuration>- Skjul tekst i anførselstegn -

    >
    > > - Vis tekst i anførselstegn -

    >
    > Those exact settings are already set.
    >
    > Thx for input and efforts!


    Hope that last sentence wasn't read as "problem solved"... :)

    regards /snedker
     
    Snedker, Sep 1, 2008
    #7
  8. Hi Snedker,

    Would you try System.Web.HttpUtility.UrlDecode?

    --
    All the best,
    Coskun SUNALI
    MVP ASP/ASP.NET
    http://sunali.com
    http://www.propeople.dk

    "Snedker" <> wrote in message
    news:...
    > On 1 Sep., 14:14, Florian Paulus <> wrote:
    >> Snedker wrote:
    >> > As part of URL I have ie:

    >>
    >> >www.website.com?test=%F8%E5%C6%D8%C5

    >>
    >> > Requesting the querystring and displaying the content on web I just
    >> > get a bunch of squares instead of the special Danish characters that I
    >> > expect. But I don't know how to decode them properly. Do you?

    >>
    >> > Any help or pointer in the right direction is greatly appreciated -
    >> > thanks in advance!

    >>
    >> > Kind regards /Snedker

    >>
    >> How are you trying to decode them?

    >
    > Using System.Web.SystemHttpUtility.UrlDecode is what I've tried, but
    > not with the result of "squares"...
    >
    > Regards /Snedker
     
    Coskun SUNALI [MVP], Sep 1, 2008
    #8
  9. Snedker

    Snedker Guest

    On 1 Sep., 16:43, "Coskun SUNALI [MVP]" <> wrote:
    > Hi Snedker,
    >
    > Would you try System.Web.HttpUtility.UrlDecode?
    >
    > --
    > All the best,
    > Coskun SUNALI


    Already tried that:

    Dim s As String = HttpContext.Current.Request("test")
    s = HttpUtility.UrlDecode(s, Encoding.UTF8)
    s = HttpUtility.HtmlDecode(s)

    and the s= lines in reverse order as well. Still no luck.

    regards /Snedker
     
    Snedker, Sep 1, 2008
    #9
  10. Snedker wrote:
    > On 1 Sep., 16:43, "Coskun SUNALI [MVP]" <> wrote:
    >> Hi Snedker,
    >>
    >> Would you try System.Web.HttpUtility.UrlDecode?
    >>
    >> --
    >> All the best,
    >> Coskun SUNALI

    >
    > Already tried that:
    >
    > Dim s As String = HttpContext.Current.Request("test")
    > s = HttpUtility.UrlDecode(s, Encoding.UTF8)
    > s = HttpUtility.HtmlDecode(s)
    >
    > and the s= lines in reverse order as well. Still no luck.
    >
    > regards /Snedker


    Are you using firefox ? I did some testing and found that i get the same
    problems as you describe unless i set in firefox about:config the
    encoding for outgoing request to use unicode to true, the default was false.

    After this it works nicely, else seems that the real querystring is
    autoconverted into some strange %u..... format and that results into
    those squares.

    Look at it in the debugger, then u see what i mean. Thats the problem
    but i dont know how to solve it, you would somehow need to find out the
    original encoding of the client sending the request and decode it
    yourself. All the builtin methods like urldecode and so on fail with the
    same unwanted result.

    Using POST however instead of GET it seems to work without any problems.

    Regards

    Florian
     
    Florian Paulus, Sep 2, 2008
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ramprasad A Padmanabhan

    function to url decode a string

    Ramprasad A Padmanabhan, Jul 23, 2003, in forum: C Programming
    Replies:
    11
    Views:
    800
    Michael B Allen
    Jul 27, 2003
  2. Xah Lee

    uencode decode url string

    Xah Lee, Jun 27, 2005, in forum: Perl Misc
    Replies:
    1
    Views:
    172
    Gunnar Hjalmarsson
    Jun 27, 2005
  3. Dotan Cohen
    Replies:
    0
    Views:
    108
    Dotan Cohen
    Jun 13, 2013
  4. Robert Kern
    Replies:
    0
    Views:
    116
    Robert Kern
    Jun 13, 2013
  5. Dotan Cohen
    Replies:
    0
    Views:
    103
    Dotan Cohen
    Jun 13, 2013
Loading...

Share This Page