pub fn base64_standard(bytes: &[u8]) -> StringExpand description
What:
Encode bytes as standard base64 with = padding (RFC 4648 section 4).
Why:
pathBytes carries exact pathname bytes inside a JSON string.
Base64 is what
ripgrep’s JSON output uses for a path that is not UTF-8 and what Go’s JSON
encoding uses for bytes;
it is unmistakably not a name,
so no reader uses it as
one by accident.
Every three input bytes become four characters;
a final group
of one or two bytes is padded to four characters with =.
In TS you’d write (pseudocode):
function base64(bytes: Uint8Array): string { return Buffer.from(bytes).toString('base64'); }