encoder/filename: Add SCSU as tables

Instead of only adding SCSU, add it as an existing table.

Allow direct SCSU and add a, perhaps, reasonable table as well.

Add byte interfaces that doesn't base64 encode the URL as well with `EncodeBytes` and `DecodeBytes`.

Fuzz tested and decode tests added.
This commit is contained in:
Klaus Post
2021-01-04 17:09:09 +01:00
committed by Nick Craig-Wood
parent 47b69d6300
commit 424aaac2e1
8 changed files with 201 additions and 24 deletions

View File

@@ -26,9 +26,12 @@ var (
const (
tableUncompressed = 0
tableRLE = 61
tableCustom = 62
tableReserved = 63
tableSCSU = 59
tableSCSUPlain = 60
tableRLE = 61
tableCustom = 62
tableReserved = 63
)
// predefined tables as base64 URL encoded string.
@@ -47,6 +50,10 @@ var tablesData = [64]string{
5: "JRDIcQf_______8PgIiIiIgINkggARHlkQwSSCCBxHFYINHdfXI=",
// Special tables:
// SCSU and a fairly generic table:
tableSCSU: "UxAgZmEB-RYPU8hrnAk6uMgpTNQMB5MGRBx0D3T0JjyUyY-yOi5CoGgktbAktSh7d36HtPTFu7SXJ7FYw_AYmA74ZH2vWgc8O6Z5jLnWnsFqU_4B",
// SCSU with no table...
tableSCSUPlain: "",
// Compressed data has its own table.
tableCustom: "",
// Reserved for extension.