Base84 deserves a place in file names

(00f.net)

17 points | by kevvok 2 days ago

4 comments

  • abound 51 minutes ago
    > Here’s the alphabet, in encoding order:

    > ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&'()+,-;=@[]^_`{}~

    Yeah I definitely don't want any of those last ~22 characters in file names if I need to do anything with them from a shell

    • Dwedit 19 minutes ago
      Even just "-" in a filename is problematic, since you can name actual files with "--" at the beginning, and the name could match a switch.
    • dgacmu 26 minutes ago
      Yeah, I'm sympathetic to their desire for compression and efficiency but base64URL is way more shell-friendly.

      I quite like base58 for human-presented identifiers also. I tend to use it instead of hex for having ~8-16 character IDs of things.

    • brookst 35 minutes ago
      What you don’t want a file named `reboot`?
  • bensyverson 47 minutes ago
    The non-alphanumeric characters are just asking for trouble. Agents will fail to escape them correctly, and the $ could expand a variable.

    Base62 (or 64, with -_) is totally sufficient.

  • Dwedit 21 minutes ago
    Meanwhile, Windows uses UTF-16 everywhere internally, so "a" and "あ" are both 2 bytes large. You'd still have to exclude surrogate pairs and the Unicode control characters from a filename.
  • zahlman 2 days ago
    > It emits groups of five characters. Five is the sweet spot: 84⁵ = 4,182,119,424, only 2.6% short of 2³².

    > That leaves enough room for a group to hold 32 bits about 95% of the time on uniformly random input, and 31 bits otherwise.

    > The encoder looks at the next 31 bits. If their value is below 84⁵ - 2³¹, there’s room for a 32nd bit. Otherwise, it consumes just those 31 bits. Either way, the value fits in five base-84 digits.

    Seems pretty awkward.