UTF-8-BOM-vs-meta-charset.html 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <!DOCTYPE html>
  2. <html lang="en" >
  3. <head>
  4. <meta charset="iso-8859-15"> <title>UTF-8 BOM vs meta charset</title>
  5. <link rel='author' title='Richard Ishida' href='mailto:ishida@w3.org'>
  6. <link rel='help' href='http://www.w3.org/TR/html5/syntax.html#the-input-byte-stream'>
  7. <link rel="stylesheet" type="text/css" href="./generatedtests.css">
  8. <script src="http://w3c-test.org/resources/testharness.js"></script>
  9. <script src="http://w3c-test.org/resources/testharnessreport.js"></script>
  10. <meta name='flags' content='http'>
  11. <meta name="assert" content="A page with a UTF-8 BOM will be recognized as UTF-8 even if the meta charset attribute declares a different encoding.">
  12. <style type='text/css'>
  13. .test div { width: 50px; }.test div { width: 90px; }
  14. </style>
  15. <link rel="stylesheet" type="text/css" href="the-input-byte-stream/support/encodingtests-utf8.css">
  16. </head>
  17. <body>
  18. <p class='title'>UTF-8 BOM vs meta charset</p>
  19. <div id='log'></div>
  20. <div class='test'><div id='box' class='ýäè'>&#xA0;</div></div>
  21. <div class='description'>
  22. <p class="assertion" title="Assertion">A page with a UTF-8 BOM will be recognized as UTF-8 even if the meta charset attribute declares a different encoding.</p>
  23. <div class="notes"><p><p>The page contains an encoding declaration in a meta charset attribute that attempts to set the character encoding to ISO 8859-15, but the file starts with a UTF-8 signature.</p><p>The test contains a div with a class name that contains the following sequence of bytes: 0xC3 0xBD 0xC3 0xA4 0xC3 0xA8. These represent different sequences of characters in ISO 8859-15, ISO 8859-1 and UTF-8. The external, UTF-8-encoded stylesheet contains a selector <code>.test div.&#x00FD;&#x00E4;&#x00E8;</code>. This matches the sequence of bytes above when they are interpreted as UTF-8. If the class name matches the selector then the test will pass.</p></p>
  24. </div>
  25. </div>
  26. <div class="nexttest"><div><a href="generate?test=the-input-byte-stream-024">Next test</a></div><div class="doctype">HTML5</div>
  27. <p class="jump">the-input-byte-stream-038<br /><a href="/International/tests/html5/the-input-byte-stream/results-basics#precedence" target="_blank">Result summary &amp; related tests</a><br /><a href="http://w3c-test.org/framework/details/i18n-html5/the-input-byte-stream-038" target="_blank">Detailed results for this test</a><br/> <a href="http://www.w3.org/TR/html5/syntax.html#the-input-byte-stream" target="_blank">Link to spec</a></p>
  28. <div class='prereq'>Assumptions: <ul><li>The default encoding for the browser you are testing is not set to ISO 8859-15.</li>
  29. <li>The test is read from a server that supports HTTP.</li></ul></div>
  30. </div>
  31. <script>
  32. test(function() {
  33. assert_equals(document.getElementById('box').offsetWidth, 100);
  34. }, " ");
  35. </script>
  36. </body>
  37. </html>