Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What you indicated as the "broken" encoded string is actually the correct encoding according to standards. The one that you indicated as "correct" encoding is using a non-standard extension to the specifications to allow a format of <code>%uXXXX</code> (I believe it's supposed to indicate UTF-16 encoding).</p> <p>In any case, the "broken" encoded string is ok. You can use the following code to test that:</p> <pre><code>Uri uri = new Uri("http://www.example.com/test.aspx?search=heřmánek"); Console.WriteLine(uri.Query); Console.WriteLine(HttpUtility.UrlDecode(uri.Query)); </code></pre> <p>Works fine. However... on a hunch, I tried UrlDecode with a Latin-1 codepage specified, instead of the default UTF-8:</p> <pre><code>Console.WriteLine(HttpUtility.UrlDecode(uri.Query, Encoding.GetEncoding("iso-8859-1"))); </code></pre> <p>... and I got the bad value you specified, 'heÅmánek'. In other words, it looks like the call to <code>HttpContext.RewritePath()</code> somehow changes the urlencoding/decoding to use the Latin-1 codepage, rather than UTF-8, which is the default encoding used by the UrlEncode/Decode methods.</p> <p>This looks like a bug if you ask me. You can look at the <code>RewritePath()</code> code in reflector and see that it is definitely playing with the querystring - passing it around to all kinds of virtual path functions, and out to some unmanaged IIS code. </p> <p>I wonder if somewhere along the way, the Uri at the core of the Request object gets manipulated with the wrong codepage? That would explain why <code>Request.Querystring</code> (which is simply the raw values from the HTTP headers) would be correct, while the Uri using the wrong encoding for the diacriticals would be incorrect.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload