Files
anki-static/AnkiStatic.Lib/Base91.fs
patrick 3e3d092c27
All checks were successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/all-checks-complete Pipeline was successful
Add JSON input (#3)
Co-authored-by: Smaug123 <patrick+github@patrickstevens.co.uk>
Reviewed-on: #3
2023-09-08 18:19:06 +00:00

25 lines
648 B
Forth

namespace AnkiStatic
open System.Text
[<RequireQualifiedAccess>]
module internal Base91 =
// Replicating the Anki algorithm
let private chars =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "0123456789"
+ "!#$%&()*+,-./:;<=>?@[]^_`{|}~"
let toString (input : uint64) : string =
let output = StringBuilder ()
let mutable input = input
while input > 0uL do
let modded = int (input % (uint64 chars.Length))
let div = input / (uint64 chars.Length)
input <- div
output.Append chars.[modded] |> ignore
output.ToString ()