base2e15 0.3.0

  • Readme
  • Changelog
  • Installing
  • 47

base2e15 #

binary-to-text encoding schemes that represent binary data in an unicode string format, each unicode character represent 15 bits of binary data

Example

EncodingDatachararacters
Plain textBase2e15 is awesome!20
Base2e15嗺둽嬖蟝巍媖疌켉溁닽壪11
Base64QmFzZTJlMTUgaXMgYXdlc29tZSE=27+1

Mapping table #

Every character represent 15 bits of data, except the last character 7 bits or 15 bits

BinaryUnicodeUnicode Range Name
15 bits mapping
0x0000 ~ 0x1935U+3480 ~ U+4DB5CJK Unified Ideographs Extension A
0x1936 ~ 0x545BU+4E00 ~ U+8925CJK Unified Ideographs
0x545C ~ 0x7FFFU+AC00 ~ U+D7A3Hangul Syllables
7 bits mapping
0x00 ~ 0x7FU+3400 ~ U+347FCJK Unified Ideographs Extension A

Usage #

A simple usage example in dart:

import 'dart:convert';
import 'package:base2e15/base2e15.dart';

main() {
  String msg = 'Base2e15 is awesome!';
  String encoded = Base2e15.encode(UTF8.encode(msg));
  String decoded = UTF8.decode(Base2e15.decode(encoded));
}

Compare #

CompareBase2e15Base64
bits per character156
bits per char width7.5 (15/2)6 (6/1)
bits per UTF8 byte5 (15/3)6 (6/1)
bits per UTF16 byte7.5 (15/2)3 (6/2)

Why not base2e16 ? #

Unicode range CJK Unified Ideographs Extension B contains 42711 characters (U+20000 ~ U+2A6D6), together with the characters used by base2e15, there are more than 65536 usable characters to encode 16 bits in each character.

However, font support for CJK Unified Ideographs Extension B is missing in most mobile devices and using this code range will also readue the bits capacity in UTF8 and UTF16 encoding, since those characters require one more byte in UTF8 and 2 more bytes in UTF16.

Changelog #

0.3.0 #

  • Dart 2 support

0.2.0 #

  • Mapping table change

0.1.1 #

  • Fix README.md

0.1.0 #

  • Initial version

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  base2e15: ^0.3.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:base2e15/base2e15.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
47
Learn more about scoring.

We analyzed this package on Jul 3, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13

Health suggestions

Fix lib/base2e15.dart. (-2.48 points)

Analysis of lib/base2e15.dart reported 5 hints:

line 18 col 14: Unnecessary new keyword.

line 28 col 33: Unnecessary new keyword.

line 30 col 18: Unnecessary new keyword.

line 40 col 21: Unnecessary new keyword.

line 80 col 21: Unnecessary new keyword.

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and base2e15.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.0.0 <3.0.0