Giter Site home page Giter Site logo

base16384.js's Introduction

Base16384

Codecov downloads npm GitHub

A unicode-based encoding scheme that presents binary data (sequence of 8-bit bytes) in sequences of 14-bit printable Chinese characters. It saves 17% space compared to base64.

Inspired by fumiama/base16384.

Description

Base16384 uses 16384 (214) Chinese characters (from \u4E00 to \u8DFF) to represent binary data.

If the length of the binary data is not a multiple of 7, we will add a \u3D0x (where x is the remainder modulo 7) after the output.

Comparison

Base64 Base16384
Overhead 33% 14%
Charset [0-9a-zA-Z+/] [\u4E00-\u8DFF]
Example RXhhbXBsZQ== 彞吖菁穥㴀

Usage

import { decode, encode } from 'base16384'

const buffer = encode('Example') // Uint16Array
new TextDecoder().decode(decode(buffer)) // 'Example'

API

encode(data)

  • data: string | Uint8Array original binary data
  • returns: Uint16Array base16384-encoded data

Encode binary data to base16384.

decode(data)

  • data: string | Uint16Array base16384-encoded data
  • returns: Uint8Array original binary data

Decode base16384 to binary data.

base16384.js's People

Contributors

shigma 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.