Coder Social home page Coder Social logo

lzw's Introduction

Introduction

A C++ STL based implementation of LZW (Lempel–Ziv–Welch) compression algorithm; inspired by the following repos:

APIs

Implemented the following encoder/decoders:

  • basic implementation Compress and Decompress
  • UTF16 CompressToUTF16 and DecompressFromUTF16
  • Base64 CompressToBase64 and DecompressFromBase64

Not yet implemented:

  • encode to/decode from EncodeURIComponent (mainly for JavaScript)

Util functions:

  • ToWStr: convert std::string to std::wstring
  • ToStr: truncted version of string convertion; convert std::wstring to std::string based on MSDN: If wcstombs_s encounters a wide character it cannot convert to a multibyte character, it puts 0 in *pReturnValue, sets the destination buffer to an empty string, sets errno to EILSEQ, and returns EILSEQ. (wcstombs and wsctombs_s always return error code 42, any one knows how to do it correctly?)

Each method provides 2 APIs for different parameters std::string and std::wstring, respectively.

Test case (non-standard / messy version):

The file data.json is used for test purpose; below is the output of local machine (seconds):

[Test Default algorithm]
string length:1161516 compress ratio:23
time elapsed (s): 0.486
checking correctness: [string compressed == decompressed]:1

[Test UTF16]
string length:1161516 compress ratio:21
time elapsed (s): 0.457
checking correctness: [string compressed == decompressed]:1

[Test Base64]
string length:1161516 compress ratio:8
time elapsed (s): 0.468
checking correctness: [string compressed == decompressed]:1

lzw's People

Contributors

fengzhyuan avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

shangaoren

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.