Commit 78099461 by Abseil Team Committed by Copybara-Service

Replace generic 'base64 encoding' terminology with the specific RFCs they match.

Remove duplicate documentation for two variants of Base64EscapeInternal().

Clarify role of base64 char array input (controls web-safe or not).

PiperOrigin-RevId: 500867221
Change-Id: Ie316a7ddd60794e041c5b9b39e9ab5b66ed565a6
parent 3e200f53
...@@ -25,19 +25,17 @@ namespace strings_internal { ...@@ -25,19 +25,17 @@ namespace strings_internal {
ABSL_CONST_INIT extern const char kBase64Chars[]; ABSL_CONST_INIT extern const char kBase64Chars[];
// Calculates how long a string will be when it is base64 encoded given its // Calculates the length of a Base64 encoding (RFC 4648) of a string of length
// length and whether or not the result should be padded. // `input_len`, with or without padding per `do_padding`. Note that 'web-safe'
// encoding (section 5 of the RFC) does not change this length.
size_t CalculateBase64EscapedLenInternal(size_t input_len, bool do_padding); size_t CalculateBase64EscapedLenInternal(size_t input_len, bool do_padding);
// Base64-encodes `src` using the alphabet provided in `base64` and writes the // Base64-encodes `src` using the alphabet provided in `base64` (which
// result to `dest`. If `do_padding` is true, `dest` is padded with '=' chars // determines whether to do web-safe encoding or not) and writes the result to
// until its length is a multiple of 3. Returns the length of `dest`. // `dest`. If `do_padding` is true, `dest` is padded with '=' chars until its
// length is a multiple of 3. Returns the length of `dest`.
size_t Base64EscapeInternal(const unsigned char* src, size_t szsrc, char* dest, size_t Base64EscapeInternal(const unsigned char* src, size_t szsrc, char* dest,
size_t szdest, const char* base64, bool do_padding); size_t szdest, const char* base64, bool do_padding);
// Base64-encodes `src` using the alphabet provided in `base64` and writes the
// result to `dest`. If `do_padding` is true, `dest` is padded with '=' chars
// until its length is a multiple of 3.
template <typename String> template <typename String>
void Base64EscapeInternal(const unsigned char* src, size_t szsrc, String* dest, void Base64EscapeInternal(const unsigned char* src, size_t szsrc, String* dest,
bool do_padding, const char* base64_chars) { bool do_padding, const char* base64_chars) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment