UrlDecode

  • Thread starter Thread starter Alex
  • Start date Start date
A

Alex

Hi,

I UrlEncode a value that I put in my querystring. This value originally
contains the character "è", which is UrlEncoded to "%E8". When I try
to read the value from the querystring, I find out that the character
now is "%u00c3%u00a8" in the querystring and thus does not urldecode to
the original character, which is a problem. My site is using CMS. Any
idea what is going on?

Thank you for any support,

Alex
 
Hi Alex,

That character should be encoded to %c3%a8, not %E8. It should appear as
%c3%a8 in the query string.

Use the System.Web.HttpUtility.UrlEncode and UrlDecode methods.

--
Dave Sexton

Hi,

I UrlEncode a value that I put in my querystring. This value originally
contains the character "è", which is UrlEncoded to "%E8". When I try
to read the value from the querystring, I find out that the character
now is "%u00c3%u00a8" in the querystring and thus does not urldecode to
the original character, which is a problem. My site is using CMS. Any
idea what is going on?

Thank you for any support,

Alex
 
Actually it does encode to %c3%a8 (I already use
HttpUtility.UrlEncode), I mixed things up writing %E8. Sorry my
mistake. But there is no mistake in my original problem tought ;) It
ends up as %u00c3%u00a8 which can be UrlDecoded correctly. Why the %u00
(I guess it means it is unicode encoding characters...)

Thanks,
 
Hi Alex,

I can't reproduce your problem. When I supply a string containing the
specified character to HttpUtility.UrlEncode it returns "%c3%a8". When I pass
"%c3%a8" to HttpUtility.UrlDecode it returns the specified character.
(verified in 2.0)

Where are you getting "%u00c3%u00a8" from?

--
Dave Sexton

Actually it does encode to %c3%a8 (I already use
HttpUtility.UrlEncode), I mixed things up writing %E8. Sorry my
mistake. But there is no mistake in my original problem tought ;) It
ends up as %u00c3%u00a8 which can be UrlDecoded correctly. Why the %u00
(I guess it means it is unicode encoding characters...)

Thanks,
 
I specified my site is using CMS. I think it comes from CMS. I am not
sure I understand how to decode the string I am getting... I'll try and
post to a CMS channel to see if anyone ever experienced something
similar.
 
Hi Alex,

That's a good idea.

GL

--
Dave Sexton

I specified my site is using CMS. I think it comes from CMS. I am not
sure I understand how to decode the string I am getting... I'll try and
post to a CMS channel to see if anyone ever experienced something
similar.
 
Anyhow, thanks for your answers!

Dave said:
Hi Alex,

That's a good idea.

GL

--
Dave Sexton

I specified my site is using CMS. I think it comes from CMS. I am not
sure I understand how to decode the string I am getting... I'll try and
post to a CMS channel to see if anyone ever experienced something
similar.
 
Thus wrote Dave,
Hi Alex,

That character should be encoded to %c3%a8, not %E8. It should appear
as %c3%a8 in the query string.

There is no "should", since there is no defined character encoding for ULR
encoding -- it can be anything sender and receiver understand.

Cheers,
 
Hi Joerg,

That is certainly true, however neither "%E8" nor "%u00c3%u00a8" are returned
using HttpUtility.UrlEncode, even when specifying any of the FCL Encodings.
It should, by default, be "%c3%a8".
 
Thus wrote Dave,
Hi Joerg,

That is certainly true, however neither "%E8" nor "%u00c3%u00a8" are
returned using HttpUtility.UrlEncode, even when specifying any of the
FCL Encodings.

Then you're doing something wrong ;-)

string s = HttpUtility.UrlEncode("è", Encoding.GetEncoding(28591));
Console.WriteLine(s);

Cheers,
 
Hi Joerg,

The OP didn't specify any encoding and so I assumed that UrlEncode was being
used without any explicit encoding specified - my mistake.

I didn't mean to imply that it's not possible for UrlEncode to return "%e8", I
simply meant that you can't get it using the "FCL encodings", such as ASCII,
UTF8, UTF7, UTF32, Unicode and BigEndianUnicode or by not specifying any
encoding at all, because that's what I tested originally. I was just trying
to explain the intent for my original response :)

To answer the OP's question, I iterated over every encoding returned by
Encoding.GetEncodings looking for one that converts the specified character to
"%u00c3%u00a8". 28591 does convert the character to %e8, just like Western
European (Windows) - 1252 (Encoding.Default for me), and a few others, but
that isn't the problem at hand. The OP needs to decode "%u00c3%u00a8" but at
this point it doesn't seem like a valid encoding that can be produced by the
framework.
 
Back
Top