{
  "test": "encoding",
  "title": "Character encodings",
  "data_version": "1.0.0",
  "seed": 20261102,
  "page": "/messy/encoding/",
  "needs": "HTTP only",
  "difficulty": "Hard",
  "what_it_tests": "Three pages where the bytes, the Content-Type header and the meta tag disagree about the encoding. Get the pound signs and curly quotes right.",
  "expect": {
    "pages": 3,
    "rule": "A byte order mark wins. Otherwise, bytes that are valid UTF-8 are UTF-8, whatever the labels say. Otherwise believe the Content-Type header.",
    "selector": "li.line"
  },
  "records": [
    {
      "url": "/messy/encoding/windows-1252/",
      "bytes": "windows-1252",
      "bom": false,
      "header": "text/html; charset=windows-1252",
      "meta": "utf-8",
      "note": "The header is right and the meta tag is wrong. The bytes are not valid UTF-8, so decoding by the meta tag gives replacement characters.",
      "lines": [
        "Crème fraîche pot, £4.50",
        "Müller’s “quiet” kettle, €39.00",
        "Café table – oak, £120.00",
        "Über-soft towel ‘Nordic’, €18.99",
        "Smørrebrød board — walnut, £27.50"
      ]
    },
    {
      "url": "/messy/encoding/mislabelled/",
      "bytes": "utf-8",
      "bom": false,
      "header": "text/html; charset=iso-8859-1",
      "meta": "utf-8",
      "note": "The header is wrong and the meta tag is right. Decoding by the header gives mojibake such as \"Ã¨\" for \"è\". A browser believes the header too.",
      "lines": [
        "Crème fraîche pot, £4.50",
        "Müller’s “quiet” kettle, €39.00",
        "Café table – oak, £120.00",
        "Über-soft towel ‘Nordic’, €18.99",
        "Smørrebrød board — walnut, £27.50"
      ]
    },
    {
      "url": "/messy/encoding/bom/",
      "bytes": "utf-8",
      "bom": true,
      "header": "text/html; charset=windows-1252",
      "meta": "utf-8",
      "note": "The body starts with the UTF-8 byte order mark EF BB BF, which outranks the header. Decode as UTF-8 and drop the mark.",
      "lines": [
        "Crème fraîche pot, £4.50",
        "Müller’s “quiet” kettle, €39.00",
        "Café table – oak, £120.00",
        "Über-soft towel ‘Nordic’, €18.99",
        "Smørrebrød board — walnut, £27.50"
      ]
    }
  ]
}
