>base91 ( seq -- base91 )
Base91 conversions

Next:base91> ( base91 -- seq )


Vocabulary
base91

Inputs
seqa sequence


Outputs
base91a sequence


Word description
Encode into Base91 encoding.

Definition


:: >base91 ( seq -- base91 )
0 :> b! 0 :> n! BV{ } clone :> accum seq [
n shift b bitor b! n 8 + n! n 13 > [
b 8191 bitand dup 88 >
[ b -13 shift b! n 13 - n! ]
[ drop b 16383 bitand b -14 shift b! n 14 - n! ] if
91 /mod swap [ ch>base91 accum push ] bi@
] when
] each n 0 > [
b 91 mod ch>base91 accum push n 7 > b 90 > or
[ b 91 /i ch>base91 accum push ] when
] when accum B{ } like ;