# package lzw
`import "compress/lzw"`
lzw包实现了Lempel-Ziv-Welch数据压缩格式,这是一种T. A. Welch在“A Technique for High-Performance Data Compression”一文(Computer, 17(6) (June 1984), pp 8-19)提出的一种压缩格式。
本包实现了用于GIF、TIFF、PDF文件的lzw压缩格式,这是一种最长达到12位的变长码,头两个非字面码为clear和EOF码。
## Index
* [type Order](#Order)
* [func NewReader(r io.Reader, order Order, litWidth int) io.ReadCloser](#NewReader)
* [func NewWriter(w io.Writer, order Order, litWidth int) io.WriteCloser](#NewWriter)
## type [Order](https://github.com/golang/go/blob/master/src/compress/lzw/reader.go#L25 "View Source")
```
type Order int
```
Order指定一个lzw数据流的位顺序。
```
const (
// LSB表示最小权重位在前,用在GIF文件格式
LSB Order = iota
// MSB表示最大权重位在前,用在TIFF和PDF文件格式
MSB
)
```
## func [NewReader](https://github.com/golang/go/blob/master/src/compress/lzw/reader.go#L225 "View Source")
```
func NewReader(r io.Reader, order Order, litWidth int) io.ReadCloser
```
创建一个io.ReadCloser,它从r读取并解压数据。调用者有责任在结束读取后调用返回值的Close方法;litWidth指定字面码的位数,必须在[2,8]范围内,一般为8。
## func [NewWriter](https://github.com/golang/go/blob/master/src/compress/lzw/writer.go#L234 "View Source")
```
func NewWriter(w io.Writer, order Order, litWidth int) io.WriteCloser
```
创建一个io.WriteCloser,它将数据压缩后写入w。调用者有责任在结束写入后调用返回值的Close方法;litWidth指定字面码的位数,必须在[2,8]范围内,一般为8。
- 库
- package achive
- package tar
- package zip
- package bufio
- package builtin
- package bytes
- package compress
- package bzip2
- package flate
- package gzip
- package lzw
- package zlib
- package container
- package heap
- package list
- package ring
- package crypto
- package aes
- package cipher
- package des
- package dsa
- package ecdsa
- package elliptic
- package hmac
- package md5
- package rand
- package rc4
- package rsa
- package sha1
- package sha256
- package sha512
- package subtle
- package tls
- package x509
- package pkix
- package database
- package sql
- package driver
- package encoding
- package ascii85
- package asn1
- package base32
- package base64
- package binary
- package csv
- package gob
- package hex
- package json
- package pem
- package xml
- package errors
- package expvar
- package flag
- package fmt
- package go
- package doc
- package format
- package parser
- package printer
- package hash
- package adler32
- package crc32
- package crc64
- package fnv
- package html
- package template
- package image
- package color
- package palette
- package draw
- package gif
- package jpeg
- package png
- package index
- package suffixarray
- package io
- package ioutil
- package log
- package syslog
- package math
- package big
- package cmplx
- package rand
- package mime
- package multipart
- package net
- package http
- package cgi
- package cookiejar
- package fcgi
- package httptest
- package httputil
- package pprof
- package mail
- package rpc
- package jsonrpc
- package smtp
- package textproto
- package url
- package os
- package exec
- package signal
- package user
- package path
- package filepath
- package reflect
- package regexp
- package runtime
- package cgo
- package debug
- package pprof
- package race
- package sort
- package strconv
- package strings
- package sync
- package atomic
- package text
- package scanner
- package tabwriter
- package template
- package time
- package unicode
- package utf16
- package utf8
- package unsafe