[{"data":1,"prerenderedAt":207},["ShallowReactive",2],{"navigation_docs":3,"-formats-lzw":84,"-formats-lzw-surround":204},[4,48],{"title":5,"path":6,"stem":7,"children":8,"icon":47},"Guide","\u002Fguide","1.guide\u002F01.index",[9,11,15,19,23,27,31,35,39,43],{"title":10,"path":6,"stem":7},"Getting Started",{"title":12,"path":13,"stem":14},"Compressing","\u002Fguide\u002Fcompressing","1.guide\u002F02.compressing",{"title":16,"path":17,"stem":18},"Containers","\u002Fguide\u002Fcontainers","1.guide\u002F03.containers",{"title":20,"path":21,"stem":22},"Checksums","\u002Fguide\u002Fchecksums","1.guide\u002F04.checksums",{"title":24,"path":25,"stem":26},"Identify and peel","\u002Fguide\u002Fidentify","1.guide\u002F05.identify",{"title":28,"path":29,"stem":30},"Limits","\u002Fguide\u002Flimits","1.guide\u002F06.limits",{"title":32,"path":33,"stem":34},"CLI","\u002Fguide\u002Fcli","1.guide\u002F07.cli",{"title":36,"path":37,"stem":38},"Agents","\u002Fguide\u002Fagents","1.guide\u002F08.agents",{"title":40,"path":41,"stem":42},"Custom formats","\u002Fguide\u002Fcustom","1.guide\u002F09.custom",{"title":44,"path":45,"stem":46},"Playground","\u002Fguide\u002Fplayground","1.guide\u002F10.playground","i-lucide-book-open",{"title":49,"path":50,"stem":51,"children":52,"icon":83},"Formats","\u002Fformats","2.formats\u002F00.index",[53,55,59,63,67,71,75,79],{"title":54,"path":50,"stem":51},"Every format",{"title":56,"path":57,"stem":58},"deflate","\u002Fformats\u002Fdeflate","2.formats\u002F01.deflate",{"title":60,"path":61,"stem":62},"bzip2","\u002Fformats\u002Fbzip2","2.formats\u002F02.bzip2",{"title":64,"path":65,"stem":66},"LZMA","\u002Fformats\u002Flzma","2.formats\u002F03.lzma",{"title":68,"path":69,"stem":70},"Zstandard","\u002Fformats\u002Fzstd","2.formats\u002F04.zstd",{"title":72,"path":73,"stem":74},"Brotli","\u002Fformats\u002Fbrotli","2.formats\u002F05.brotli",{"title":76,"path":77,"stem":78},"LZ4","\u002Fformats\u002Flz4","2.formats\u002F06.lz4",{"title":80,"path":81,"stem":82},"Unix compress","\u002Fformats\u002Flzw","2.formats\u002F07.lzw","i-lucide-library",{"id":85,"title":80,"body":86,"description":197,"extension":198,"links":199,"meta":200,"navigation":201,"path":81,"seo":202,"stem":82,"__hash__":203},"docs\u002F2.formats\u002F07.lzw.md",{"type":87,"value":88,"toc":192},"minimark",[89,93,106,144,162,165,168,172,182,188],[90,91],"format-facts",{"name":92},"lzw",[94,95,96,97,101,102,105],"p",{},"Older than gzip, older than most of the internet. LZW builds a dictionary as it reads: every new code is an old code plus one byte. Codes start at 9 bits and widen as the dictionary fills, up to ",[98,99,100],"code",{},"bits",". In block mode a clear code throws the dictionary away and starts over. ",[98,103,104],{},"compress"," sends one when its ratio starts slipping. The writer here never does, it keeps the full table, and the reader takes clear codes wherever they come.",[107,108,113],"pre",{"className":109,"code":110,"language":111,"meta":112,"style":112},"language-ts shiki shiki-themes compressions compressions compressions","compress(\"lzw\", \"hello world!\");  \u002F\u002F 17 bytes, 1f9d90…\n","ts","",[98,114,115],{"__ignoreMap":112},[116,117,120,123,127,131,134,137,140],"span",{"class":118,"line":119},"line",1,[116,121,104],{"class":122},"sK71F",[116,124,126],{"class":125},"s38Sx","(",[116,128,130],{"class":129},"shU9J","\"lzw\"",[116,132,133],{"class":125},", ",[116,135,136],{"class":129},"\"hello world!\"",[116,138,139],{"class":125},");  ",[116,141,143],{"class":142},"scIB-","\u002F\u002F 17 bytes, 1f9d90…\n",[94,145,146,147,150,151,153,154,157,158,161],{},"The third byte is ",[98,148,149],{},"90",": block mode on, 16 bits. That's what ",[98,152,104],{}," writes and what ",[98,155,156],{},"gzip -d"," and ",[98,159,160],{},"uncompress"," read.",[163,164,100],"h2",{"id":100},[94,166,167],{},"From 10 to 16, 16 by default. Fewer bits means a smaller dictionary, which is what old machines with little memory needed. The reader takes 9 too, and widens to 10 the way gzip and ncompress do, so a 9-bit file reads the same here as there.",[163,169,171],{"id":170},"the-quirk","The quirk",[94,173,174,175,178,179,181],{},"When codes widen, compress skips to the end of the current group of eight codes. Those padding bits are in every ",[98,176,177],{},".Z"," file ever written, and a reader that doesn't skip them reads garbage after the first width change. This one skips them, and the writer writes them, so ",[98,180,160],{}," reads what it makes.",[94,183,184,185,187],{},"No checksum, no stored size. A damaged ",[98,186,177],{}," file decodes into the wrong bytes without a word.",[189,190,191],"style",{},"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":112,"searchDepth":193,"depth":193,"links":194},2,[195,196],{"id":100,"depth":193,"text":100},{"id":170,"depth":193,"text":171},"Lempel-Ziv-Welch with codes from 9 to 16 bits. The .Z files compress wrote and gzip still reads","md",null,{},true,{"title":80,"description":197},"U5-XbyWhfZjhn6M4cZGYqRiVqJZeieSJ2SNSV7YYaaI",[205,199],{"title":76,"path":77,"stem":78,"description":206,"children":-1},"Byte-aligned LZ77 with no entropy coding at all. The frame with its XXH32 checks and the legacy frame",1791071141270]