[{"data":1,"prerenderedAt":871},["ShallowReactive",2],{"navigation_docs":3,"-guide-custom":128,"-guide-custom-surround":866},[4,40],{"title":5,"path":6,"stem":7,"children":8,"icon":39},"Guide","\u002Fguide","1.guide\u002F01.index",[9,11,15,19,23,27,31,35],{"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},"Custom Encodings","\u002Fguide\u002Fcustom","1.guide\u002F07.custom",{"title":36,"path":37,"stem":38},"Playground","\u002Fguide\u002Fplayground","1.guide\u002F08.playground","i-lucide-book-open",{"title":41,"path":42,"stem":43,"children":44,"icon":127},"Encodings","\u002Fencodings","2.encodings\u002F00.index",[45,47,51,55,59,63,67,71,75,79,83,87,91,95,99,103,107,111,115,119,123],{"title":46,"path":42,"stem":43},"Every encoding",{"title":48,"path":49,"stem":50},"Binary","\u002Fencodings\u002Fbinary","2.encodings\u002F01.binary",{"title":52,"path":53,"stem":54},"Hex","\u002Fencodings\u002Fhex","2.encodings\u002F02.hex",{"title":56,"path":57,"stem":58},"Base32","\u002Fencodings\u002Fbase32","2.encodings\u002F03.base32",{"title":60,"path":61,"stem":62},"Base32hex","\u002Fencodings\u002Fbase32hex","2.encodings\u002F04.base32hex",{"title":64,"path":65,"stem":66},"Crockford's Base32","\u002Fencodings\u002Fbase32-crockford","2.encodings\u002F05.base32-crockford",{"title":68,"path":69,"stem":70},"z-base-32","\u002Fencodings\u002Fz-base-32","2.encodings\u002F06.z-base-32",{"title":72,"path":73,"stem":74},"Base45","\u002Fencodings\u002Fbase45","2.encodings\u002F07.base45",{"title":76,"path":77,"stem":78},"Base58","\u002Fencodings\u002Fbase58","2.encodings\u002F08.base58",{"title":80,"path":81,"stem":82},"Base58Check","\u002Fencodings\u002Fbase58check","2.encodings\u002F09.base58check",{"title":84,"path":85,"stem":86},"Base58 (Flickr)","\u002Fencodings\u002Fbase58-flickr","2.encodings\u002F10.base58-flickr",{"title":88,"path":89,"stem":90},"Base58 (Ripple)","\u002Fencodings\u002Fbase58-ripple","2.encodings\u002F11.base58-ripple",{"title":92,"path":93,"stem":94},"Base64","\u002Fencodings\u002Fbase64","2.encodings\u002F12.base64",{"title":96,"path":97,"stem":98},"Base64url","\u002Fencodings\u002Fbase64url","2.encodings\u002F13.base64url",{"title":100,"path":101,"stem":102},"Ascii85","\u002Fencodings\u002Fascii85","2.encodings\u002F14.ascii85",{"title":104,"path":105,"stem":106},"Z85","\u002Fencodings\u002Fz85","2.encodings\u002F15.z85",{"title":108,"path":109,"stem":110},"basE91","\u002Fencodings\u002Fbase91","2.encodings\u002F16.base91",{"title":112,"path":113,"stem":114},"Bech32","\u002Fencodings\u002Fbech32","2.encodings\u002F17.bech32",{"title":116,"path":117,"stem":118},"Bech32m","\u002Fencodings\u002Fbech32m","2.encodings\u002F18.bech32m",{"title":120,"path":121,"stem":122},"uuencode","\u002Fencodings\u002Fuuencode","2.encodings\u002F19.uuencode",{"title":124,"path":125,"stem":126},"Quoted-Printable","\u002Fencodings\u002Fquoted-printable","2.encodings\u002F20.quoted-printable","i-lucide-library",{"id":129,"title":32,"body":130,"description":860,"extension":861,"links":862,"meta":863,"navigation":348,"path":33,"seo":864,"stem":34,"__hash__":865},"docs\u002F1.guide\u002F07.custom.md",{"type":131,"value":132,"toc":854},"minimark",[133,138,147,301,312,316,785,790,794,827,831,850],[134,135,137],"h2",{"id":136},"the-interface","The interface",[139,140,141,142,146],"p",{},"Every built-in is an ",[143,144,145],"code",{},"Encoding",", and yours is the same shape:",[148,149,154],"pre",{"className":150,"code":151,"language":152,"meta":153,"style":153},"language-ts shiki shiki-themes encodings encodings encodings","interface Encoding {\n  readonly name: string;\n  info(): EncodingInfo;\n  encode(input: string | Uint8Array, options?: EncodeOptions): string;\n  decode(text: string): { bytes: Uint8Array; details: Record\u003Cstring, string | number> };\n}\n","ts","",[143,155,156,173,191,207,244,295],{"__ignoreMap":153},[157,158,161,165,169],"span",{"class":159,"line":160},"line",1,[157,162,164],{"class":163},"skH_V","interface",[157,166,168],{"class":167},"sK71F"," Encoding",[157,170,172],{"class":171},"s38Sx"," {\n",[157,174,176,179,182,185,188],{"class":159,"line":175},2,[157,177,178],{"class":163},"  readonly",[157,180,181],{"class":171}," name",[157,183,184],{"class":163},":",[157,186,187],{"class":167}," string",[157,189,190],{"class":171},";\n",[157,192,194,197,200,202,205],{"class":159,"line":193},3,[157,195,196],{"class":167},"  info",[157,198,199],{"class":171},"()",[157,201,184],{"class":163},[157,203,204],{"class":167}," EncodingInfo",[157,206,190],{"class":171},[157,208,210,213,216,218,220,223,226,229,232,235,238,240,242],{"class":159,"line":209},4,[157,211,212],{"class":167},"  encode",[157,214,215],{"class":171},"(input",[157,217,184],{"class":163},[157,219,187],{"class":167},[157,221,222],{"class":163}," |",[157,224,225],{"class":167}," Uint8Array",[157,227,228],{"class":171},", options",[157,230,231],{"class":163},"?:",[157,233,234],{"class":167}," EncodeOptions",[157,236,237],{"class":171},")",[157,239,184],{"class":163},[157,241,187],{"class":167},[157,243,190],{"class":171},[157,245,247,250,253,255,257,259,261,264,266,268,271,273,276,279,282,285,287,289,292],{"class":159,"line":246},5,[157,248,249],{"class":167},"  decode",[157,251,252],{"class":171},"(text",[157,254,184],{"class":163},[157,256,187],{"class":167},[157,258,237],{"class":171},[157,260,184],{"class":163},[157,262,263],{"class":171}," { bytes",[157,265,184],{"class":163},[157,267,225],{"class":167},[157,269,270],{"class":171},"; details",[157,272,184],{"class":163},[157,274,275],{"class":167}," Record",[157,277,278],{"class":171},"\u003C",[157,280,281],{"class":167},"string",[157,283,284],{"class":171},", ",[157,286,281],{"class":167},[157,288,222],{"class":163},[157,290,291],{"class":167}," number",[157,293,294],{"class":171},"> };\n",[157,296,298],{"class":159,"line":297},6,[157,299,300],{"class":171},"}\n",[139,302,303,304,307,308,311],{},"No base class. ",[143,305,306],{},"info()"," describes it. Label, family, standard and the alphabet. Whether it has a checksum or padding. The options ",[143,309,310],{},"encode"," takes.",[134,313,315],{"id":314},"octal-because-a-puzzle-said-so","Octal, because a puzzle said so",[148,317,319],{"className":150,"code":318,"language":152,"meta":153,"style":153},"import { DecodeError, encode, identify, register, type Encoding } from \"@agntn\u002Fencodings\";\n\nconst octal: Encoding = {\n  name: \"octal\",\n  info: () => ({\n    name: \"octal\",\n    label: \"Octal\",\n    description: \"Three octal digits per byte, the way od -b prints them\",\n    family: \"octal\",\n    standard: \"od -b\",\n    alphabet: \"01234567\",\n    checksum: false,\n    padding: false,\n    options: [],\n  }),\n  encode: (input) =>\n    Array.from(typeof input === \"string\" ? new TextEncoder().encode(input) : input, (byte) =>\n      byte.toString(8).padStart(3, \"0\"),\n    ).join(\" \"),\n  decode(text) {\n    const groups = text.trim().split(\u002F\\s+\u002Fu);\n    if (groups.some((group) => !\u002F^[0-3][0-7]{2}$\u002Fu.test(group))) {\n      throw new DecodeError(\"octal\", \"every byte is three digits, 000 to 377\");\n    }\n    return { bytes: Uint8Array.from(groups, (group) => Number.parseInt(group, 8)), details: {} };\n  },\n};\n\nregister(octal);\nencode(\"octal\", \"hi\");              \u002F\u002F \"150 151\"\nidentify(\"150 151\")[0]?.encoding;   \u002F\u002F \"octal\"\n",[143,320,321,344,350,367,378,391,400,411,422,432,443,454,460,466,472,478,489,536,560,576,584,624,668,690,696,721,727,733,738,747,768],{"__ignoreMap":153},[157,322,323,326,329,332,335,338,342],{"class":159,"line":160},[157,324,325],{"class":163},"import",[157,327,328],{"class":171}," { DecodeError, encode, identify, register, ",[157,330,331],{"class":163},"type",[157,333,334],{"class":171}," Encoding } ",[157,336,337],{"class":163},"from",[157,339,341],{"class":340},"shU9J"," \"@agntn\u002Fencodings\"",[157,343,190],{"class":171},[157,345,346],{"class":159,"line":175},[157,347,349],{"emptyLinePlaceholder":348},true,"\n",[157,351,352,355,358,360,362,365],{"class":159,"line":193},[157,353,354],{"class":163},"const",[157,356,357],{"class":171}," octal",[157,359,184],{"class":163},[157,361,168],{"class":167},[157,363,364],{"class":163}," =",[157,366,172],{"class":171},[157,368,369,372,375],{"class":159,"line":209},[157,370,371],{"class":171},"  name: ",[157,373,374],{"class":340},"\"octal\"",[157,376,377],{"class":171},",\n",[157,379,380,382,385,388],{"class":159,"line":246},[157,381,196],{"class":167},[157,383,384],{"class":171},": () ",[157,386,387],{"class":163},"=>",[157,389,390],{"class":171}," ({\n",[157,392,393,396,398],{"class":159,"line":297},[157,394,395],{"class":171},"    name: ",[157,397,374],{"class":340},[157,399,377],{"class":171},[157,401,403,406,409],{"class":159,"line":402},7,[157,404,405],{"class":171},"    label: ",[157,407,408],{"class":340},"\"Octal\"",[157,410,377],{"class":171},[157,412,414,417,420],{"class":159,"line":413},8,[157,415,416],{"class":171},"    description: ",[157,418,419],{"class":340},"\"Three octal digits per byte, the way od -b prints them\"",[157,421,377],{"class":171},[157,423,425,428,430],{"class":159,"line":424},9,[157,426,427],{"class":171},"    family: ",[157,429,374],{"class":340},[157,431,377],{"class":171},[157,433,435,438,441],{"class":159,"line":434},10,[157,436,437],{"class":171},"    standard: ",[157,439,440],{"class":340},"\"od -b\"",[157,442,377],{"class":171},[157,444,446,449,452],{"class":159,"line":445},11,[157,447,448],{"class":171},"    alphabet: ",[157,450,451],{"class":340},"\"01234567\"",[157,453,377],{"class":171},[157,455,457],{"class":159,"line":456},12,[157,458,459],{"class":171},"    checksum: false,\n",[157,461,463],{"class":159,"line":462},13,[157,464,465],{"class":171},"    padding: false,\n",[157,467,469],{"class":159,"line":468},14,[157,470,471],{"class":171},"    options: [],\n",[157,473,475],{"class":159,"line":474},15,[157,476,477],{"class":171},"  }),\n",[157,479,481,483,486],{"class":159,"line":480},16,[157,482,212],{"class":167},[157,484,485],{"class":171},": (input) ",[157,487,488],{"class":163},"=>\n",[157,490,492,495,497,500,503,506,509,512,515,518,521,524,526,529,531,534],{"class":159,"line":491},17,[157,493,494],{"class":171},"    Array.",[157,496,337],{"class":167},[157,498,499],{"class":171},"(",[157,501,502],{"class":163},"typeof",[157,504,505],{"class":171}," input ",[157,507,508],{"class":163},"===",[157,510,511],{"class":340}," \"string\"",[157,513,514],{"class":163}," ?",[157,516,517],{"class":163}," new",[157,519,520],{"class":167}," TextEncoder",[157,522,523],{"class":171},"().",[157,525,310],{"class":167},[157,527,528],{"class":171},"(input) ",[157,530,184],{"class":163},[157,532,533],{"class":171}," input, (byte) ",[157,535,488],{"class":163},[157,537,539,542,545,548,551,554,557],{"class":159,"line":538},18,[157,540,541],{"class":171},"      byte.",[157,543,544],{"class":167},"toString",[157,546,547],{"class":171},"(8).",[157,549,550],{"class":167},"padStart",[157,552,553],{"class":171},"(3, ",[157,555,556],{"class":340},"\"0\"",[157,558,559],{"class":171},"),\n",[157,561,563,566,569,571,574],{"class":159,"line":562},19,[157,564,565],{"class":171},"    ).",[157,567,568],{"class":167},"join",[157,570,499],{"class":171},[157,572,573],{"class":340},"\" \"",[157,575,559],{"class":171},[157,577,579,581],{"class":159,"line":578},20,[157,580,249],{"class":167},[157,582,583],{"class":171},"(text) {\n",[157,585,587,590,593,596,599,602,604,607,609,612,615,618,621],{"class":159,"line":586},21,[157,588,589],{"class":163},"    const",[157,591,592],{"class":171}," groups ",[157,594,595],{"class":163},"=",[157,597,598],{"class":171}," text.",[157,600,601],{"class":167},"trim",[157,603,523],{"class":171},[157,605,606],{"class":167},"split",[157,608,499],{"class":171},[157,610,611],{"class":340},"\u002F\\s",[157,613,614],{"class":163},"+",[157,616,617],{"class":340},"\u002F",[157,619,620],{"class":163},"u",[157,622,623],{"class":171},");\n",[157,625,627,630,633,636,639,641,644,646,649,652,655,657,659,662,665],{"class":159,"line":626},22,[157,628,629],{"class":163},"    if",[157,631,632],{"class":171}," (groups.",[157,634,635],{"class":167},"some",[157,637,638],{"class":171},"((group) ",[157,640,387],{"class":163},[157,642,643],{"class":163}," !",[157,645,617],{"class":340},[157,647,648],{"class":163},"^",[157,650,651],{"class":340},"[0-3][0-7]",[157,653,654],{"class":163},"{2}$",[157,656,617],{"class":340},[157,658,620],{"class":163},[157,660,661],{"class":171},".",[157,663,664],{"class":167},"test",[157,666,667],{"class":171},"(group))) {\n",[157,669,671,674,676,679,681,683,685,688],{"class":159,"line":670},23,[157,672,673],{"class":163},"      throw",[157,675,517],{"class":163},[157,677,678],{"class":167}," DecodeError",[157,680,499],{"class":171},[157,682,374],{"class":340},[157,684,284],{"class":171},[157,686,687],{"class":340},"\"every byte is three digits, 000 to 377\"",[157,689,623],{"class":171},[157,691,693],{"class":159,"line":692},24,[157,694,695],{"class":171},"    }\n",[157,697,699,702,705,707,710,712,715,718],{"class":159,"line":698},25,[157,700,701],{"class":163},"    return",[157,703,704],{"class":171}," { bytes: Uint8Array.",[157,706,337],{"class":167},[157,708,709],{"class":171},"(groups, (group) ",[157,711,387],{"class":163},[157,713,714],{"class":171}," Number.",[157,716,717],{"class":167},"parseInt",[157,719,720],{"class":171},"(group, 8)), details: {} };\n",[157,722,724],{"class":159,"line":723},26,[157,725,726],{"class":171},"  },\n",[157,728,730],{"class":159,"line":729},27,[157,731,732],{"class":171},"};\n",[157,734,736],{"class":159,"line":735},28,[157,737,349],{"emptyLinePlaceholder":348},[157,739,741,744],{"class":159,"line":740},29,[157,742,743],{"class":167},"register",[157,745,746],{"class":171},"(octal);\n",[157,748,750,752,754,756,758,761,764],{"class":159,"line":749},30,[157,751,310],{"class":167},[157,753,499],{"class":171},[157,755,374],{"class":340},[157,757,284],{"class":171},[157,759,760],{"class":340},"\"hi\"",[157,762,763],{"class":171},");              ",[157,765,767],{"class":766},"scIB-","\u002F\u002F \"150 151\"\n",[157,769,771,774,776,779,782],{"class":159,"line":770},31,[157,772,773],{"class":167},"identify",[157,775,499],{"class":171},[157,777,778],{"class":340},"\"150 151\"",[157,780,781],{"class":171},")[0]?.encoding;   ",[157,783,784],{"class":766},"\u002F\u002F \"octal\"\n",[139,786,787,789],{},[143,788,743],{}," replaces anything with the same name, built-ins included. Want your own base64 that pads differently? You can. Should you? Probably not.",[134,791,793],{"id":792},"what-comes-for-free","What comes for free",[139,795,796,797,284,799,284,802,284,805,808,809,812,813,815,816,819,820,823,824,826],{},"Once registered, ",[143,798,310],{},[143,800,801],{},"decode",[143,803,804],{},"create",[143,806,807],{},"encodings()"," and ",[143,810,811],{},"encodingInfos()"," all know it. So does ",[143,814,773],{},", with no extra wiring. So do the tools in the same process. ",[143,817,818],{},"info().alphabet"," feeds the small alphabet score. ",[143,821,822],{},"checksum: true"," gets the checksum score. Only claim a checksum your ",[143,825,801],{}," actually checks.",[134,828,830],{"id":829},"errors","Errors",[139,832,833,834,837,838,841,842,845,846,849],{},"Throw ",[143,835,836],{},"DecodeError"," for text that isn't valid. ",[143,839,840],{},"ChecksumError"," for a checksum that doesn't match. ",[143,843,844],{},"InvalidOptionError"," for a bad option. All three extend ",[143,847,848],{},"EncodingError",". The CLI turns that into one line on stderr, the MCP server into a tool error. Anything else counts as a bug and keeps its stack trace.",[851,852,853],"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 .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);}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)}",{"title":153,"searchDepth":175,"depth":175,"links":855},[856,857,858,859],{"id":136,"depth":175,"text":137},{"id":314,"depth":175,"text":315},{"id":792,"depth":175,"text":793},{"id":829,"depth":175,"text":830},"An encoding is one object with a name and info and encode and decode. Register it and everything sees it","md",null,{},{"title":32,"description":860},"_mVZeQK_cBbQbLE9E5UPN3jz9JqSK85nwL1E4sancyk",[867,869],{"title":28,"path":29,"stem":30,"description":868,"children":-1},"The same four tools over MCP and Pi and OMP and the AI SDK. What they take and what they refuse and what the model reads back",{"title":36,"path":37,"stem":38,"description":870,"children":-1},"The four tools in your browser with the CLI line and the tool call for every state",1790940133608]