Question

I have some simple HTML which has a link to another HTML file - but that file name contains a unicode character. Depending upon how I encode the link, IE on Windows will not open it - and yet the very same link works on all the other browsers (Windows and Mac) Any pointers would be most welcome.

What seems to be key here is that I'm opening the HTML on a local disk (i.e. it's not being served up by a web server.)

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>website</title>
</head>
<body>

<a href="%C3%A9.html">Fails on IE - works everywhere else (Firefox, Chrome, Safari)</a>
<p />
<a href="é.html">Works on IE</a>

</html>

Thanks

Craig

Was it helpful?

Solution

This is discussed in the following IEBlog article on MSDN:

File URIs in Windows

Non US-ASCII Characters

Characters outside of US-ASCII may appear in Windows file paths and accordingly they’re allowed in file IRIs. (URIs are defined as US-ASCII only and so when including non-US-ASCII characters in a string, what you've actually created is called an IRI: Internationalized Resource Identifier.) Don’t use percent-encoded octets to represent non US-ASCII characters because, in file URIs, percent-encoded octets are interpreted as a byte in the user’s current codepage. The meaning of a URI containing percent-encoded octets for bytes outside of US-ASCII will change depending on the locale in which the document is viewed. Instead, to represent a non-US-ASCII character you should use that character directly in the encoding of the document in which you are writing the IRI. For instance:

Incorrect: file:///C:/example%E3%84%93.txt
Correct: file:///C:/exampleㄓ.txt

In other words, since your HTML is using UTF-8, the URL must use non-percent-encoded UTF-8 octets for the é character, which is why é.html works and %C3%A9.html fails - there is no file named é.html, for example.

This is how Internet Explorer is designed to work. It is not a bug. The other browsers are simply doing something different, that's all. Unless you can configure the webserver to deliver different HTML to IE vs other browsers, you will have to use client-side technology instead, such as conditional comments, eg:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9">
<title>website</title>
</head>
<body>

<!--[if IE]>
<a href="é.html">Works on IE</a>
<![endif]-->
<!--[if !IE]> -->
<a href="%C3%A9.html">Works everywhere else</a>
<!-- <![endif]-->

</html>

The X-UA-Compatible meta tag is needed because Microsoft removed support for HTML conditional comments in IE 10 when it implemented support for HTML5.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top