international characters in url

  • Thread starter Thread starter Peter Kirk
  • Start date Start date
P

Peter Kirk

Hi

I need some help with sending "international" charcters in a parameter
string to a web application. I need to send the following for example:

http://localhost/myapp/TestAdmin.aspx?sort=å

Even though I see the Danish letter 'å' (a little 'a' with a circle over) in
the url, and if I "view source" on the web-page, the application itself
receives a strange character combination when it tries to extract the
parameter from the request.

If I do:
string sort = Request.Params["sort"];
then the variable sort recieves the value:
Ã¥

How can get the real value 'å' ?

Thanks,
Peter
 
RFC 1738: "...Only alphanumerics [0-9a-zA-Z], the special characters
"$-_.+!*'()," and reserved characters used for their reserved purposes may
be used unencoded within a URL."

You need to url-encode the string; see HttpUtility.UrlEncode

http://msdn2.microsoft.com/en-us/library/s2x4538s.aspx

Note that it is already decoded when reading a request via the methods you
are using, hence it is decoding a non-encoded string, which is why it is
currently wrong. The url is incorrect.

Marc
 
I now see that only the parameter list should be url-encoded
Technically, just the *individual components* of the list, not the
entire query-string itself (otherwise the separaters (?&= etc) will be
encoded, which you don't want). But I think you "get it", so I'll shut
up.

Happy coding,

Marc
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top