[{"data":1,"prerenderedAt":519},["ShallowReactive",2],{"navigation_docs":3,"-encodings-html":140,"-encodings-html-surround":514},[4,52],{"title":5,"path":6,"stem":7,"children":8,"icon":51},"Guide","\u002Fguide","1.guide\u002F01.index",[9,11,15,19,23,27,31,35,39,43,47],{"title":10,"path":6,"stem":7},"Getting Started",{"title":12,"path":13,"stem":14},"Encoding and Decoding","\u002Fguide\u002Fencoding","1.guide\u002F02.encoding",{"title":16,"path":17,"stem":18},"Checksums","\u002Fguide\u002Fchecksums","1.guide\u002F03.checksums",{"title":20,"path":21,"stem":22},"Identify","\u002Fguide\u002Fidentify","1.guide\u002F04.identify",{"title":24,"path":25,"stem":26},"CLI","\u002Fguide\u002Fcli","1.guide\u002F05.cli",{"title":28,"path":29,"stem":30},"Agents","\u002Fguide\u002Fagents","1.guide\u002F06.agents",{"title":32,"path":33,"stem":34},"Code pages","\u002Fguide\u002Fcode-pages","1.guide\u002F07.code-pages",{"title":36,"path":37,"stem":38},"RLP","\u002Fguide\u002Frlp","1.guide\u002F08.rlp",{"title":40,"path":41,"stem":42},"OpenPGP armor","\u002Fguide\u002Farmor","1.guide\u002F09.armor",{"title":44,"path":45,"stem":46},"Custom Encodings","\u002Fguide\u002Fcustom","1.guide\u002F10.custom",{"title":48,"path":49,"stem":50},"Playground","\u002Fguide\u002Fplayground","1.guide\u002F11.playground","i-lucide-book-open",{"title":53,"path":54,"stem":55,"children":56,"icon":139},"Encodings","\u002Fencodings","2.encodings\u002F00.index",[57,59,63,67,71,75,79,83,87,91,95,99,103,107,111,115,119,123,127,131,135],{"title":58,"path":54,"stem":55},"Every encoding",{"title":60,"path":61,"stem":62},"Binary","\u002Fencodings\u002Fbinary","2.encodings\u002F01.binary",{"title":64,"path":65,"stem":66},"Octal","\u002Fencodings\u002Foctal","2.encodings\u002F02.octal",{"title":68,"path":69,"stem":70},"Decimal","\u002Fencodings\u002Fdecimal","2.encodings\u002F03.decimal",{"title":72,"path":73,"stem":74},"Integer","\u002Fencodings\u002Finteger","2.encodings\u002F03.integer",{"title":76,"path":77,"stem":78},"Hex","\u002Fencodings\u002Fhex","2.encodings\u002F04.hex",{"title":80,"path":81,"stem":82},"Base32","\u002Fencodings\u002Fbase32","2.encodings\u002F05.base32",{"title":84,"path":85,"stem":86},"Base45","\u002Fencodings\u002Fbase45","2.encodings\u002F09.base45",{"title":88,"path":89,"stem":90},"Base58","\u002Fencodings\u002Fbase58","2.encodings\u002F10.base58",{"title":92,"path":93,"stem":94},"Base64","\u002Fencodings\u002Fbase64","2.encodings\u002F14.base64",{"title":96,"path":97,"stem":98},"Base85","\u002Fencodings\u002Fbase85","2.encodings\u002F18.base85",{"title":100,"path":101,"stem":102},"basE91","\u002Fencodings\u002Fbase91","2.encodings\u002F19.base91",{"title":104,"path":105,"stem":106},"Base256","\u002Fencodings\u002Fbase256","2.encodings\u002F20.base256",{"title":108,"path":109,"stem":110},"Bech32","\u002Fencodings\u002Fbech32","2.encodings\u002F21.bech32",{"title":112,"path":113,"stem":114},"uuencode","\u002Fencodings\u002Fuuencode","2.encodings\u002F22.uuencode",{"title":116,"path":117,"stem":118},"Quoted-Printable","\u002Fencodings\u002Fquoted-printable","2.encodings\u002F23.quoted-printable",{"title":120,"path":121,"stem":122},"HTML","\u002Fencodings\u002Fhtml","2.encodings\u002F24.html",{"title":124,"path":125,"stem":126},"ITA2","\u002Fencodings\u002Fita2","2.encodings\u002F25.ita2",{"title":128,"path":129,"stem":130},"Prefix codes","\u002Fencodings\u002Fprefix","2.encodings\u002F26.prefix",{"title":132,"path":133,"stem":134},"Chess squares","\u002Fencodings\u002Fsquare","2.encodings\u002F27.square",{"title":136,"path":137,"stem":138},"FEN","\u002Fencodings\u002Ffen","2.encodings\u002F28.fen","i-lucide-library",{"id":141,"title":120,"body":142,"description":508,"extension":509,"links":510,"meta":511,"navigation":238,"path":121,"seo":512,"stem":122,"__hash__":513},"docs\u002F2.encodings\u002F24.html.md",{"type":143,"value":144,"toc":502},"minimark",[145,149,166,280,303,329,332,337,343,385,404,412,419,438,444,448,465,485,492,498],[146,147],"encoding-facts",{"name":148},"html",[150,151,152,153,157,158,161,162,165],"p",{},"A page can't just write ",[154,155,156],"code",{},"\u003C"," in its text. The parser would take it for a tag. So HTML spells it ",[154,159,160],{},"&lt;",", and the ampersand spells itself ",[154,163,164],{},"&amp;",". That's a character reference.",[167,168,173],"pre",{"className":169,"code":170,"language":171,"meta":172,"style":172},"language-ts shiki shiki-themes encodings encodings encodings","const read = (text: string) => new TextDecoder().decode(decode(\"html\", text).bytes);\n\nencode(\"html\", 'Tom & \"Jerry\" \u003C3');  \u002F\u002F \"Tom &amp; &quot;Jerry&quot; &lt;3\"\nread(\"Universit&auml;t\");            \u002F\u002F \"Universität\"\n","ts","",[154,174,175,233,240,263],{"__ignoreMap":172},[176,177,180,184,188,191,195,198,201,204,207,210,213,216,219,222,224,226,230],"span",{"class":178,"line":179},"line",1,[176,181,183],{"class":182},"skH_V","const",[176,185,187],{"class":186},"sK71F"," read",[176,189,190],{"class":182}," =",[176,192,194],{"class":193},"s38Sx"," (text",[176,196,197],{"class":182},":",[176,199,200],{"class":186}," string",[176,202,203],{"class":193},") ",[176,205,206],{"class":182},"=>",[176,208,209],{"class":182}," new",[176,211,212],{"class":186}," TextDecoder",[176,214,215],{"class":193},"().",[176,217,218],{"class":186},"decode",[176,220,221],{"class":193},"(",[176,223,218],{"class":186},[176,225,221],{"class":193},[176,227,229],{"class":228},"shU9J","\"html\"",[176,231,232],{"class":193},", text).bytes);\n",[176,234,236],{"class":178,"line":235},2,[176,237,239],{"emptyLinePlaceholder":238},true,"\n",[176,241,243,246,248,250,253,256,259],{"class":178,"line":242},3,[176,244,245],{"class":186},"encode",[176,247,221],{"class":193},[176,249,229],{"class":228},[176,251,252],{"class":193},", ",[176,254,255],{"class":228},"'Tom & \"Jerry\" \u003C3'",[176,257,258],{"class":193},");  ",[176,260,262],{"class":261},"scIB-","\u002F\u002F \"Tom &amp; &quot;Jerry&quot; &lt;3\"\n",[176,264,266,269,271,274,277],{"class":178,"line":265},4,[176,267,268],{"class":186},"read",[176,270,221],{"class":193},[176,272,273],{"class":228},"\"Universit&auml;t\"",[176,275,276],{"class":193},");            ",[176,278,279],{"class":261},"\u002F\u002F \"Universität\"\n",[150,281,282,283,252,286,252,288,252,291,294,295,298,299,302],{},"Encoding escapes the five characters markup cares about: ",[154,284,285],{},"&",[154,287,156],{},[154,289,290],{},">",[154,292,293],{},"\""," and ",[154,296,297],{},"'",". Everything else stays put. Want plain ASCII out? ",[154,300,301],{},"ascii: true"," writes the rest as hex references too.",[167,304,306],{"className":169,"code":305,"language":171,"meta":172,"style":172},"encode(\"html\", \"Zażółć gęślą\", { ascii: true });\n\u002F\u002F \"Za&#x17C;&#xF3;&#x142;&#x107; g&#x119;&#x15B;l&#x105;\"\n",[154,307,308,324],{"__ignoreMap":172},[176,309,310,312,314,316,318,321],{"class":178,"line":179},[176,311,245],{"class":186},[176,313,221],{"class":193},[176,315,229],{"class":228},[176,317,252],{"class":193},[176,319,320],{"class":228},"\"Zażółć gęślą\"",[176,322,323],{"class":193},", { ascii: true });\n",[176,325,326],{"class":178,"line":235},[176,327,328],{"class":261},"\u002F\u002F \"Za&#x17C;&#xF3;&#x142;&#x107; g&#x119;&#x15B;l&#x105;\"\n",[150,330,331],{},"Ugly? Sure. It survives any charset, though.",[333,334,336],"h2",{"id":335},"reading-it-like-a-browser","Reading it like a browser",[150,338,339,340,342],{},"Decoding is the fun part. A browser never throws on a bad reference. It shrugs and keeps going. ",[154,341,218],{}," does the same, rule for rule from the WHATWG tokenizer.",[344,345,346,357,366,376],"ul",{},[347,348,349,350,352,353,356],"li",{},"Every named reference in the spec's table, from ",[154,351,164],{}," to ",[154,354,355],{},"&CounterClockwiseContourIntegral;",".",[347,358,359,360,294,363,356],{},"Decimal and hex ones, ",[154,361,362],{},"&#65;",[154,364,365],{},"&#x1F600;",[347,367,368,369,372,373,356],{},"The old names that still work without a semicolon. ",[154,370,371],{},"&copy 2001"," is ",[154,374,375],{},"© 2001",[347,377,378,379,382,383,356],{},"Anything that names nothing stays text. ",[154,380,381],{},"AT&T"," comes back as ",[154,384,381],{},[150,386,387,388,391,392,395,396,399,400,403],{},"And ",[154,389,390],{},"&notit;","? That's ",[154,393,394],{},"¬it;",". ",[154,397,398],{},"not"," is one of the old names, ",[154,401,402],{},"notit"," isn't a name at all. Browsers really do this.",[333,405,407,408,411],{"id":406},"why-is-146-an-apostrophe","Why is ",[154,409,410],{},"&#146;"," an apostrophe?",[150,413,414,415,418],{},"Because Windows said so. Code point 146 is an invisible control character. But pages from the nineties were typed in Windows-1252, where byte 146 is ",[154,416,417],{},"’",". Their authors wrote what they saw.",[167,420,422],{"className":169,"code":421,"language":171,"meta":172,"style":172},"read(\"it&#146;s &#150; &#128;5\");  \u002F\u002F \"it’s – €5\"\n",[154,423,424],{"__ignoreMap":172},[176,425,426,428,430,433,435],{"class":178,"line":179},[176,427,268],{"class":186},[176,429,221],{"class":193},[176,431,432],{"class":228},"\"it&#146;s &#150; &#128;5\"",[176,434,258],{"class":193},[176,436,437],{"class":261},"\u002F\u002F \"it’s – €5\"\n",[150,439,440,441,356],{},"So browsers read 128 to 159 through Windows-1252, and this does too. Zero, surrogates and anything past U+10FFFF turn into ",[154,442,443],{},"�",[333,445,447],{"id":446},"spotting-it-in-the-wild","Spotting it in the wild",[150,449,450,453,454,395,457,460,461,464],{},[154,451,452],{},"identify"," wants at least one reference that ends in ",[154,455,456],{},";",[154,458,459],{},"R&D"," is valid HTML too. It just never said anything. Same for a URL with ",[154,462,463],{},"&copy=2"," in its query.",[167,466,468],{"className":169,"code":467,"language":171,"meta":172,"style":172},"identify(\"Universit&auml;t, it&#146;s 1999\")[0]?.text;  \u002F\u002F \"Universität, it’s 1999\"\n",[154,469,470],{"__ignoreMap":172},[176,471,472,474,476,479,482],{"class":178,"line":179},[176,473,452],{"class":186},[176,475,221],{"class":193},[176,477,478],{"class":228},"\"Universit&auml;t, it&#146;s 1999\"",[176,480,481],{"class":193},")[0]?.text;  ",[176,483,484],{"class":261},"\u002F\u002F \"Universität, it’s 1999\"\n",[150,486,487,488,491],{},"Base64 wrapped around a page? ",[154,489,490],{},"peel"," takes off both layers.",[150,493,494,495,497],{},"It's text in and text out, so there's no overhead on random bytes. Hand ",[154,496,245],{}," bytes that aren't UTF-8 and it refuses. A reference names a character, never a raw byte.",[499,500,501],"style",{},"html pre.shiki code .skH_V, html code.shiki .skH_V{--shiki-light:var(--shiki-token-keyword);--shiki-default:var(--shiki-token-keyword);--shiki-dark:var(--shiki-token-keyword)}html pre.shiki code .sK71F, html code.shiki .sK71F{--shiki-light:var(--shiki-token-function);--shiki-default:var(--shiki-token-function);--shiki-dark:var(--shiki-token-function)}html pre.shiki code .s38Sx, html code.shiki .s38Sx{--shiki-light:var(--ui-text-highlighted);--shiki-default:var(--ui-text-highlighted);--shiki-dark:var(--ui-text-highlighted)}html pre.shiki code .shU9J, html code.shiki .shU9J{--shiki-light:var(--shiki-token-string);--shiki-default:var(--shiki-token-string);--shiki-dark:var(--shiki-token-string)}html pre.shiki code .scIB-, html code.shiki .scIB-{--shiki-light:var(--shiki-token-comment);--shiki-default:var(--shiki-token-comment);--shiki-dark:var(--shiki-token-comment)}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":172,"searchDepth":235,"depth":235,"links":503},[504,505,507],{"id":335,"depth":235,"text":336},{"id":406,"depth":235,"text":506},"Why is &#146; an apostrophe?",{"id":446,"depth":235,"text":447},"HTML character references. Every named one in the WHATWG table, decimal and hex ones, and the Windows-1252 quirks old pages still carry","md",null,{},{"title":120,"description":508},"KHWoRhy1_ZVE4aVnbiYwV7xcbWpLSivFw8cwno_SyD0",[515,517],{"title":116,"path":117,"stem":118,"description":516,"children":-1},"RFC 2045 Quoted-Printable. Printable ASCII stays and the rest becomes =XX with soft breaks past 76 characters",{"title":124,"path":125,"stem":126,"description":518,"children":-1},"Baudot-Murray teleprinter code in five bits, with the letters and figures shifts handled for you",1794584246049]