Giter VIP home page Giter VIP logo

utfz's Introduction

UTFZ

UTFZ is a small utf16 compression library.

How does it work?

Consider the following utf16 representation of "Hello":

48 00 65 00 6c 00 6c 00 6f 00

You can see that all the odd bytes are 00.

Consider the following utf16 representation of the Farsi word "سلام":

33 06 44 06 27 06 45 06

You can see that all the odd bytes are 06 and this pattern repeats itself. These are wasted bytes. The letters of each language, are incrementally one after another and share the same high byte most of the time. Utfz assumes the high byte is equal to 00 and changes it every time it encounters a 00.

With utfz, the first word becomes:

48 65 6c 6c 6f

and the second one becomes:

00 06 33 44 27 45

Where the first 00 tells the decoder to set the high byte to 06. Words of different languages with different high bytes can be combined:

48 65 6c 6c 6f 00 06 33 44 27 45

To escape a low byte that equals 00, utfz adds the current high byte after the low byte in the sequence.

Check the source code for more info.

utfz's People

Contributors

pouya-eghbali avatar

Stargazers

 avatar Navid Hosseinzadeh avatar Andy Gower avatar Brian Dombrowski avatar Robert Sasak avatar  avatar

Watchers

James Cloos avatar  avatar

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.