1 <!DOCTYPE HTML> 2 <meta charset="ISO-8859-1"> 3 <!-- Starts with UTF-8 BOM --> 4 <p>Test: 5 <pre><!DOCTYPE HTML> 6 <meta charset="ISO-8859-1"> 7 <!-- Starts with UTF-8 BOM --></pre> 8 <p>Expected result: <span id="expected">UTF-8</span> 9 <div> 10 <style scoped> 11 .pass { background: green; color: white; padding: 0.5em; font-weight: bold; } 12 .fail { background: red; color: yellow; padding: 0.5em; font-weight: bold; } 13 </style> 14 <p>Encoding used by browser is: <span id="encoding">Script did not run.</span> 15 <p>Result: <span id="result">Script did not run.</span> 16 <script> 17 var encoding = 'unknown'; 18 if ('' == '\u00E0') { // 0xE0 19 if ('' == '\u2122') { // 0x99 20 if ('' == '\u00FE') // 0xFE 21 encoding = 'Windows-1252'; 22 else if ('' == '\u015F') 23 encoding = 'Windows-1254'; 24 else if ('' == '\u200F') 25 encoding = 'Windows-1256'; 26 else if ('' == '\u20AB') 27 encoding = 'Windows-1258'; 28 else 29 encoding = 'unknown with 0xE0 = U+00E0 and 0x99 = U+2122'; 30 } else if ('' == '\u02D9') // 0xFF 31 encoding = 'ISO-8859-3'; 32 else if ('' == '\u0177') // 0xFE 33 encoding = 'ISO-8859-14'; 34 else if ('' == '\u021B') 35 encoding = 'ISO-8859-16'; 36 else if ('' == '\u015F') 37 encoding = 'ISO-8859-9'; 38 else if ('' == '\u00BE') // 0xBE 39 encoding = 'ISO-8859-1'; 40 else if ('' == '\u0178') 41 encoding = 'ISO-8859-15'; 42 else 43 encoding = 'unknown with 0xE0 = U+00E0'; 44 } else if ('' == '\u0101') // 0xE0 45 encoding = 'ISO-8859-10'; 46 else if ('' == '\u0E40') // 0xE0 47 encoding = 'ISO-8859-11'; 48 else if ('' == '\uFFFD') { // 0xE0 49 if ('' == '\u263A') // 0xE2 0x98 0xBA 50 encoding = 'UTF-8'; 51 else 52 encoding = 'unknown (but ASCII-compatible)'; 53 } 54 document.getElementById('encoding').firstChild.data = encoding; 55 var expected = document.getElementById('expected').firstChild.data; 56 if (expected == '(demo - no expected result)') { 57 document.getElementById('result').firstChild.data = 'demo'; 58 } else if (encoding == expected) { 59 document.getElementById('result').firstChild.data = 'PASS'; 60 document.getElementById('result').className = 'pass'; 61 } else { 62 document.getElementById('result').firstChild.data = 'FAIL'; 63 document.getElementById('result').className = 'fail'; 64 } 65 if (parent.receivedResults) 66 parent.receivedResults(); 67 </script> 68 </div> 69