Skip to content

Instantly share code, notes, and snippets.

@jimpick
Last active October 31, 2020 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimpick/48152df88f91838bbb830e2a36732750 to your computer and use it in GitHub Desktop.
Save jimpick/48152df88f91838bbb830e2a36732750 to your computer and use it in GitHub Desktop.
"base256unismush" is an experimental multibase encoding

"unismush" multibase demo

$ npx -q @jimpick/cid-tool format -b base256unismush -v 1 bafybeifrtkrxkf3ildbhqojpr52nrk7i3s3we6qwtvw4vmkrycbzr6cki4
iJ˲ĨľꞌзӀ˹ĭˡˆᴳ˼Ȋƚῑ˸ᵋꞁᵝᵏɿˑ˾Ĭі˯ᴻꞌʿᴱϳЈᵻʶʳ
$ npx -q @jimpick/cid-tool base32 iJ˲ĨľꞌзӀ˹ĭˡˆᴳ˼Ȋƚῑ˸ᵋꞁᵝᵏɿˑ˾Ĭі˯ᴻꞌʿᴱϳЈᵻʶʳ
bafybeifrtkrxkf3ildbhqojpr52nrk7i3s3we6qwtvw4vmkrycbzr6cki4

When using a proportional font, the "unismushed" CID is half the size visually.

Multibase encoding Encoded CID
base58 (CIDv0) QmaHwdno7vA1kGWpRsFse9PN9iXYjQ2VsN7zxipKVZXzvJ
base32 bafybeifrtkrxkf3ildbhqojpr52nrk7i3s3we6qwtvw4vmkrycbzr6cki4
base256unismush iJ˲ĨľꞌзӀ˹ĭˡˆᴳ˼Ȋƚῑ˸ᵋꞁᵝᵏɿˑ˾Ĭі˯ᴻꞌʿᴱϳЈᵻʶʳ

What?

It's a multibase encoding with 256 code points, using visually narrow unicode characters from multiple languages.

Warnings

  • I'm still iterating on what unicode characters to choose from and how to map them
  • Line breaking behaviour is still a bit odd
  • Some characters came from RTL languages (Arabic) or some other characters with special behaviours may have snuck in
  • It would be nice if ASCII characters mapped to close thin relatives
  • Not all fonts will have all the unicode characters selected -- needs cross-platform testing. Several characters are not available in mobile Safari on iOS.

Why?

More bytes, but more compact visually. Can still double-click and cut-and-paste. 1:1 mapping between glyphs and bytes.

@jimpick
Copy link
Author

jimpick commented Oct 31, 2020

Code is here: https://github.com/jimpick/js-multibase/blob/jim/base256unismush/src/constants.js#L76

I didn't need to change much - the difficult part was just finding the narrow glyphs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment