YaK:: Bubble Babble Encoding [Changes]   [Calendar]   [Search]   [Index]   [PhotoTags]

## Bubble Babble Encoding

Strick designed something similar once, with the same alternation of ConsonantVowelConsonantVowelConsonant, but this one by Antti Huima is far better, with checksums and nice (subliminal) begin & end markers.

Here's the spec:

 Bubble_Babble_Encoding.txt

Here's test vectors:

```   ASCII Input       Encoding
------------------------------------------------------------------
`' (empty string) `xexax'
`1234567890'      `xesef-disof-gytuf-katof-movif-baxux'
`Pineapple'       `xigak-nyryk-humil-bosek-sonax'
```

Notice the encoding always begins & ends with "x", so the elements of the encoding of `Pineapple' are not xigak nyryk humil bosek & sonax but rather igak-n yryk-h umil-b osek-s & a final partial record ona .

Here's the meat of it:

```   Below, _|X|_ denotes the largest integer not greater than X.

Let the data to be encoded be D[1] ... D[K] where K is the length
of the data in bytes; every D[i] is an integer from 0 to 2^8 - 1.
First define the checksum series C[1] ... C[_|K/2|_] where

C[1] = 1

C[n] = (C[n - 1] * 5 + (D[n * 2 - 3] * 7 + D[n * 2 - 2])) mod 36

The data is then transformed into _|K/2|_ `tuples'
T[1] ... T[_|K/2|_] and one `partial tuple' P so that

T[i] = <a, b, c, d, e>

where

a = (((D[i * 2 - 3] >> 6) & 3) + C[i]) mod 6
b = (D[i * 2 - 3] >> 2) & 15
c = (((D[i * 2 - 3]) & 3) + _|C[i] / 6|_) mod 6
d = (D[i * 2 - 2] >> 4) & 15; and
e = (D[i * 2 - 3]) & 15.

The partial tuple P is

P = <a, b, c>

where if K is even then

a = (C[i]) mod 6
b = 16
c = _|C[i] / 6|_

but if it is odd then

a = (((D[K] >> 6) & 3) + C[i]) mod 6
b = (D[K] >> 2) & 15
c = (((D[K]) & 3) + _|C[i] / 6|_) mod 6

The `vowel table' V maps integers between 0 and 5 to vowels as

0 - a
1 - e
2 - i
3 - o
4 - u
5 - y

and the `consonant table' C maps integers between 0 and 16 to
consonants as

0 - b
1 - c
2 - d
3 - f
4 - g
5 - h
6 - k
7 - l
8 - m
9 - n
10 - p
11 - r
12 - s
13 - t
14 - v
15 - z
16 - x

The encoding E(T) of a tuple T = <a, b, c, d, e> is then the string

V[a] C[b] V[c] C[d] `-' C[e]

where there are five characters, and `-' is the literal hyphen.

The encoding E(P) of a partial tuple P = <a, b, c> is the
three-character string

V[a] C[b] V[c].

Finally, the encoding of the whole input data D is obtained as

`x' E(T[1]) E(T[2]) ... E(T[_|K/2|_]) E(P) `x'

where `x's are literal characters.
```