bottom-software-foundation / spec

A spec for the bottom encoding format.
MIT License
100 stars 1 forks source link

Official Bottom specification

v0.2.0

Bottom is a lightweight encoding format used by Discord and Tumblr users from all around the world. This document aims to detail the Bottom specification officially, so that implementing it correctly is as easy as possible.

Character table

Each character in Bottom holds a purpose of some sort. These are detailed here for your convenience, and will be referred to in depth below.

Value characters

Unicode escape(s) Character Value
U+1FAC2 πŸ«‚ Integer 200
U+1F496 πŸ’– Integer 50
U+2728 ✨ Integer 10
U+1F97A πŸ₯Ί Integer 5
U+002C , Integer 1
U+2764, U+FE0F ❀️ Integer 0

Special characters

Unicode escape(s) Character Purpose
U+1F449, U+1F448 πŸ‘‰πŸ‘ˆ Byte terminator

Notes on encoding

Notes on decoding

Example encoding implementation

For each byte b of the input stream:

An implementation can thus be expressed as the following pseudo-code:

let o = new string
for b in input_stream:
    let v = b as number

    if v is 0:
        o.append("❀️")
    else:
        loop:
            if v >= 200:
                o.append("πŸ«‚")
                v = v - 200
            else if v >= 50:
                o.append("πŸ’–")
                v = v - 50
            else if v >= 10:
                o.append("✨")
                v = v - 10
            else if v >= 5:
                o.append("πŸ₯Ί")
                v = v - 5
            else if v >= 1:
                o.append(",")
                v = v - 1
            else:
                break

    o.append("πŸ‘‰πŸ‘ˆ")

return o