[{"data":1,"prerenderedAt":674},["ShallowReactive",2],{"navigation_docs":3,"-guide-encoding":128,"-guide-encoding-surround":669},[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":12,"body":130,"description":663,"extension":664,"links":665,"meta":666,"navigation":176,"path":13,"seo":667,"stem":14,"__hash__":668},"docs\u002F1.guide\u002F02.encoding.md",{"type":131,"value":132,"toc":656},"minimark",[133,138,241,278,289,375,379,396,403,455,459,467,540,553,557,564,597,600,604,607,615,645,652],[134,135,137],"h2",{"id":136},"by-name","By name",[139,140,145],"pre",{"className":141,"code":142,"language":143,"meta":144,"style":144},"language-ts shiki shiki-themes encodings encodings encodings","import { decode, encode } from \"@agntn\u002Fencodings\";\n\nencode(\"hex\", \"gm\");             \u002F\u002F \"676d\"\nencode(\"hex\", \"gm\", { upper: true });\ndecode(\"hex\", \"0x67 6D\").bytes;  \u002F\u002F Uint8Array [103, 109]\n","ts","",[146,147,148,171,178,204,220],"code",{"__ignoreMap":144},[149,150,153,157,161,164,168],"span",{"class":151,"line":152},"line",1,[149,154,156],{"class":155},"skH_V","import",[149,158,160],{"class":159},"s38Sx"," { decode, encode } ",[149,162,163],{"class":155},"from",[149,165,167],{"class":166},"shU9J"," \"@agntn\u002Fencodings\"",[149,169,170],{"class":159},";\n",[149,172,174],{"class":151,"line":173},2,[149,175,177],{"emptyLinePlaceholder":176},true,"\n",[149,179,181,185,188,191,194,197,200],{"class":151,"line":180},3,[149,182,184],{"class":183},"sK71F","encode",[149,186,187],{"class":159},"(",[149,189,190],{"class":166},"\"hex\"",[149,192,193],{"class":159},", ",[149,195,196],{"class":166},"\"gm\"",[149,198,199],{"class":159},");             ",[149,201,203],{"class":202},"scIB-","\u002F\u002F \"676d\"\n",[149,205,207,209,211,213,215,217],{"class":151,"line":206},4,[149,208,184],{"class":183},[149,210,187],{"class":159},[149,212,190],{"class":166},[149,214,193],{"class":159},[149,216,196],{"class":166},[149,218,219],{"class":159},", { upper: true });\n",[149,221,223,226,228,230,232,235,238],{"class":151,"line":222},5,[149,224,225],{"class":183},"decode",[149,227,187],{"class":159},[149,229,190],{"class":166},[149,231,193],{"class":159},[149,233,234],{"class":166},"\"0x67 6D\"",[149,236,237],{"class":159},").bytes;  ",[149,239,240],{"class":202},"\u002F\u002F Uint8Array [103, 109]\n",[242,243,244,245,193,248,251,252,255,256,259,260,263,264,193,267,263,270,273,274,277],"p",{},"The name is forgiving. ",[146,246,247],{},"Base 64",[146,249,250],{},"base_64"," and ",[146,253,254],{},"b64"," all find ",[146,257,258],{},"base64",". ",[146,261,262],{},"qp"," finds ",[146,265,266],{},"quoted-printable",[146,268,269],{},"btoa",[146,271,272],{},"ascii85",". A name nobody knows throws ",[146,275,276],{},"UnknownEncodingError",". The message lists every name, so you don't guess twice.",[242,279,280,281,284,285,288],{},"Options are checked against what the encoding declares. Pass ",[146,282,283],{},"upper"," to base64 and you get ",[146,286,287],{},"InvalidOptionError",", not a silent nothing. Only six encodings take options at all.",[290,291,292,305],"table",{},[293,294,295],"thead",{},[296,297,298,302],"tr",{},[299,300,301],"th",{},"Encoding",[299,303,304],{},"Options",[306,307,308,320,332,343,361],"tbody",{},[296,309,310,316],{},[311,312,313],"td",{},[146,314,315],{},"hex",[311,317,318],{},[146,319,283],{},[296,321,322,327],{},[311,323,324],{},[146,325,326],{},"binary",[311,328,329],{},[146,330,331],{},"separate",[296,333,334,338],{},[311,335,336],{},[146,337,272],{},[311,339,340],{},[146,341,342],{},"delimiters",[296,344,345,353],{},[311,346,347,193,350],{},[146,348,349],{},"bech32",[146,351,352],{},"bech32m",[311,354,355,193,358],{},[146,356,357],{},"prefix",[146,359,360],{},"limit",[296,362,363,367],{},[311,364,365],{},[146,366,120],{},[311,368,369,193,372],{},[146,370,371],{},"name",[146,373,374],{},"mode",[134,376,378],{"id":377},"what-comes-back","What comes back",[242,380,381,383,384,387,388,391,392,395],{},[146,382,225],{}," returns ",[146,385,386],{},"{ bytes, details }",". The bytes are a ",[146,389,390],{},"Uint8Array",", always. Want text? Run them through ",[146,393,394],{},"TextDecoder"," yourself. The library won't guess that your bytes are UTF-8.",[242,397,398,399,402],{},"And ",[146,400,401],{},"details","? That's the part of the text that isn't data.",[139,404,406],{"className":141,"code":405,"language":143,"meta":144,"style":144},"decode(\"bech32\", \"bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4\").details;\n\u002F\u002F { prefix: \"bc\", witnessVersion: 0 }\n\ndecode(\"uuencode\", \"begin 644 cat.txt\\n#0V%T\\n`\\nend\\n\").details;\n\u002F\u002F { mode: \"644\", name: \"cat.txt\" }\n",[146,407,408,425,430,434,450],{"__ignoreMap":144},[149,409,410,412,414,417,419,422],{"class":151,"line":152},[149,411,225],{"class":183},[149,413,187],{"class":159},[149,415,416],{"class":166},"\"bech32\"",[149,418,193],{"class":159},[149,420,421],{"class":166},"\"bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4\"",[149,423,424],{"class":159},").details;\n",[149,426,427],{"class":151,"line":173},[149,428,429],{"class":202},"\u002F\u002F { prefix: \"bc\", witnessVersion: 0 }\n",[149,431,432],{"class":151,"line":180},[149,433,177],{"emptyLinePlaceholder":176},[149,435,436,438,440,443,445,448],{"class":151,"line":206},[149,437,225],{"class":183},[149,439,187],{"class":159},[149,441,442],{"class":166},"\"uuencode\"",[149,444,193],{"class":159},[149,446,447],{"class":166},"\"begin 644 cat.txt\\n#0V%T\\n`\\nend\\n\"",[149,449,424],{"class":159},[149,451,452],{"class":151,"line":222},[149,453,454],{"class":202},"\u002F\u002F { mode: \"644\", name: \"cat.txt\" }\n",[134,456,458],{"id":457},"codec-objects","Codec objects",[242,460,461,462,251,464,466],{},"Every encoding is also a plain object with ",[146,463,184],{},[146,465,225],{},". No registry involved.",[139,468,470],{"className":141,"code":469,"language":143,"meta":144,"style":144},"import { base58, base58check, hex } from \"@agntn\u002Fencodings\";\n\nbase58.encode(new TextEncoder().encode(\"hello world\"));  \u002F\u002F \"StV1DL6CwTryKyV\"\nbase58check.decode(\"1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa\");\n\u002F\u002F 21 bytes: version 0x00, then the HASH160\n",[146,471,472,485,489,520,535],{"__ignoreMap":144},[149,473,474,476,479,481,483],{"class":151,"line":152},[149,475,156],{"class":155},[149,477,478],{"class":159}," { base58, base58check, hex } ",[149,480,163],{"class":155},[149,482,167],{"class":166},[149,484,170],{"class":159},[149,486,487],{"class":151,"line":173},[149,488,177],{"emptyLinePlaceholder":176},[149,490,491,494,496,498,501,504,507,509,511,514,517],{"class":151,"line":180},[149,492,493],{"class":159},"base58.",[149,495,184],{"class":183},[149,497,187],{"class":159},[149,499,500],{"class":155},"new",[149,502,503],{"class":183}," TextEncoder",[149,505,506],{"class":159},"().",[149,508,184],{"class":183},[149,510,187],{"class":159},[149,512,513],{"class":166},"\"hello world\"",[149,515,516],{"class":159},"));  ",[149,518,519],{"class":202},"\u002F\u002F \"StV1DL6CwTryKyV\"\n",[149,521,522,525,527,529,532],{"class":151,"line":206},[149,523,524],{"class":159},"base58check.",[149,526,225],{"class":183},[149,528,187],{"class":159},[149,530,531],{"class":166},"\"1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa\"",[149,533,534],{"class":159},");\n",[149,536,537],{"class":151,"line":222},[149,538,539],{"class":202},"\u002F\u002F 21 bytes: version 0x00, then the HASH160\n",[242,541,542,543,546,547,193,549,552],{},"These work on bytes. ",[146,544,545],{},"hex.decode"," returns a ",[146,548,390],{},[146,550,551],{},"base58.encode"," wants one. The registry just wraps them.",[134,554,556],{"id":555},"subpaths","Subpaths",[242,558,559,560,563],{},"Each family has its own entry. Pulling base58 into a bundle doesn't drag the registry along. Or ",[146,561,562],{},"identify",". Or sixteen other alphabets.",[139,565,567],{"className":141,"code":566,"language":143,"meta":144,"style":144},"import { base58, base58check } from \"@agntn\u002Fencodings\u002Fbase58\";\nimport { bech32, segwit } from \"@agntn\u002Fencodings\u002Fbech32\";\n",[146,568,569,583],{"__ignoreMap":144},[149,570,571,573,576,578,581],{"class":151,"line":152},[149,572,156],{"class":155},[149,574,575],{"class":159}," { base58, base58check } ",[149,577,163],{"class":155},[149,579,580],{"class":166}," \"@agntn\u002Fencodings\u002Fbase58\"",[149,582,170],{"class":159},[149,584,585,587,590,592,595],{"class":151,"line":173},[149,586,156],{"class":155},[149,588,589],{"class":159}," { bech32, segwit } ",[149,591,163],{"class":155},[149,593,594],{"class":166}," \"@agntn\u002Fencodings\u002Fbech32\"",[149,596,170],{"class":159},[242,598,599],{},"Eleven families, one subpath each. A test bundles every one of them and fails if another family's code sneaks in.",[134,601,603],{"id":602},"decoding-is-strict-mostly","Decoding is strict, mostly",[242,605,606],{},"Where a spec says something is wrong, decoding says so. It names the offending character and its index.",[139,608,613],{"className":609,"code":611,"language":612,"meta":144},[610],"language-text","base58: \"0\" (U+0030) at index 0 is not in the alphabet\nbase64: 1 padding characters where the length needs 2\n","text",[146,614,611],{"__ignoreMap":144},[242,616,617,618,621,622,625,626,251,629,632,633,625,636,639,640,644],{},"Real text often comes wrapped, though. So decoding reads through the wrapping. Base64 and base32 skip line breaks and spaces, and a MIME body decodes as it is. Hex takes either case, spaces and a ",[146,619,620],{},"0x",". Crockford reads ",[146,623,624],{},"O"," as ",[146,627,628],{},"0",[146,630,631],{},"I"," or ",[146,634,635],{},"L",[146,637,638],{},"1",". That's the whole point of Crockford. Want the rules per encoding? Every ",[641,642,643],"a",{"href":42},"encoding page"," lists them.",[242,646,647,648,651],{},"An invisible character never reaches the message raw. A U+2028 shows up as ",[146,649,650],{},"U+2028",". Not as a line break that rewrites the error under your feet.",[653,654,655],"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 .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 .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 .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":144,"searchDepth":173,"depth":173,"links":657},[658,659,660,661,662],{"id":136,"depth":173,"text":137},{"id":377,"depth":173,"text":378},{"id":457,"depth":173,"text":458},{"id":555,"depth":173,"text":556},{"id":602,"depth":173,"text":603},"Two calls by name, a codec object per encoding and a subpath per family. Strings are UTF-8 and bytes stay bytes","md",null,{},{"title":12,"description":663},"3hN_26QSNaGkXgLiHb-DXhEMmINQsXMPP8bczhYOJ1M",[670,672],{"title":10,"path":6,"stem":7,"description":671,"children":-1},"Install the package and decode your first string. Every encoding answers the same two calls",{"title":16,"path":17,"stem":18,"description":673,"children":-1},"Base58Check and bech32 and bech32m verify themselves on decode. A segwit address comes back as its version and program",1790940133287]