This is not a new queestion
There are quite a few of questions here on SO about IE having some problems with handling special characters in the querystrings. In all of the cases it is the same: Chrome, Firefox, Safari (everyone) handles the UTF-8 encoded URLs correctly, almost all of them even handles the cases where the IRIs aren't encoded into URLs. But IE insists on make life hard for the developers.
As I have run into the problem myself, and have worked quite a bit with it. To me it seems that IE for some reason insists on decoding the UTF-8 encoded URL into ISO-8859-1 before sending it to the server.
My case
I am a resident in Denmark, and therefor I have to work with the danish letters æøå. There a many cases where I want to send parameters from my views into some C# methods. Two examples of such places where the special characters often pop up:
- Searching
- Specification of filename for a downloaded files
Say a Dane wants to search for the danish word "æblegrød" (special kind of apple pie). In Chrome and Firefox, if I just feed the browser with the IRI:
http://example.com/Search/QuickSearch?searchQuery=æblegrød
The query sent to the server would look like this:
http://example.com/Search/QuickSearch?searchQuery=%C3%A6blegr%C3%B8d
In Internet Explorer however it would look like this:
http://example.com/Search/QuickSearch?searchQuery=æblegrød
It is now easy to see what the problem is. Firefox & Chrome are URL encoding the URLs
... each byte that is not an ASCII letter or digit to %HH, where HH is the hexadecimal value of the byte
Where Internet Exlorer instead is doing a direct UTF-8 encoding of the string, resulting in "æblegrød". This is also the same end results as if you take a UTF-8 string and decode it as if it was ISO-8859-1, is this a coincidence?
I have tried some things
As Internet Explorer has the option to "send URL path as UTF-8" I tried disabling that. Changing nothing.
As it went wrong when IE has to handle "searchQuery=æblegrød" I tried encoding the IRI before handing it to the browser. Resulting in all browsers getting the following URL to work with:
http://example.com/Search/QuickSearch?searchQuery=%C3%A6blegr%C3%B8d
IE however doesn't care, what I see in the networking log is still the URL
http://example.com/Search/QuickSearch?searchQuery=æblegrød
being sent to the server.
This is how my configuration is:
- Files are saved as UTF-8
I set the meta tag:
<meta charset="UTF-8">
IE sends URL-paths as UTF-8 (also set IE to do this for intranet querystrings)
Globalization set to UTF-8
<globalization uiCulture="da-DK" culture="da-Dk" fileEncoding="utf-8" responseEncoding="utf-8" requestEncoding="utf-8" responseHeaderEncoding="utf-8" />
I am running out of ideas, I don't know what it is that I am doing wrong. I am leaning towards IE creating the havoc, but I genuinely do not know if it is something that I have set up wrongly in my project.