Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ASP.NET - UrlDecode loses some characters- BUG?

447 views
Skip to first unread message

JD

unread,
Sep 4, 2003, 1:33:03 PM9/4/03
to
Hello,
I have an application where ASP page writes a cookie and ASP.NET pages reads
the cookie and displays it on the page - no problem.
I use Server.UrlDecode method in ASP.NET page to decode the cookie so it
doesn't display the text in cookie encoded. This work s fine too.

But the problem starts when the cookie contains special/foreign characters.
After invoking UrlDecode it will drop all special/foreign characters and
displays only the rest of the string. I tried not to use UrlDecode to see if
the characters get lost before invoking UrlDecode but they are still there.
Also other (classsic) ASP pages have no problem reading cookies with
special/foreign characters and displaying them correctly.

I even tried to take encoded string with special/foreign characters, used
UrlDecode directly on this string (not reading from cookie) and it still
displays it incorrectly so I think the problem is somewhere with UrlDecode
method.

I tried this
response.write
(Server.UrlDecode("%2D%2D%EC%9A%E8%F8%9E%FD%E1%ED%E9%2A%2A"))
and it displays this
--**
instead of
--escrzЩАМИ** (see the attached picture to see the characters if this
doesn't display properly)

Is it a bug or is a feature in UrlDecode ? If it is a feature is there a
solution how to display all characters correctly?

Thanks a lot
JD

characters.gif

Rick Strahl [MVP]

unread,
Sep 4, 2003, 2:03:45 PM9/4/03
to
JD,

I think this has to do with the character set used in the original string.

You might want to try the HttpUtility.UrlDecode() method which supports a
character encoding parameter. I suspect the base version is dealing with
ASCII encoding whcih wouldn't show the extended chars...

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/wwHelp
----------------------------------
Making waves on the Web


"JD" <skl...@hotmail.com> wrote in message
news:uBxJZqwc...@TK2MSFTNGP09.phx.gbl...

JD

unread,
Sep 4, 2003, 3:04:58 PM9/4/03
to
Whow...miracle happened it - works...thanks a lot for your help!!!

for anyone who strugles with a similar problem I used:

HttpUtility.UrlDecode(request.cookies("somecookie").values("somevalue"),Syst
em.Text.Encoding.Default)

I tried other encodings (UTF8) but it didn't seem to work, Default on the
other hand works perfectly.

Thanks a lot for your help Rick.
Have a nice day.
JD

"Rick Strahl [MVP]" <ricks...@hotmail.com> wrote in message
news:#szTl7wc...@TK2MSFTNGP10.phx.gbl...

0 new messages