summaryrefslogtreecommitdiff
path: root/absl/strings/internal/escaping.h
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2023-01-09 19:08:03 -0800
committerGravatar Copybara-Service <copybara-worker@google.com>2023-01-09 19:08:55 -0800
commit78099461ac99ee8e7e515046c802d569a4642bd2 (patch)
treea85d7c8c4fd69c43f6ad164e6c647cc02e9582a6 /absl/strings/internal/escaping.h
parent3e200f539fd6523a26a89dd21b1c966f3e8b1486 (diff)
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
Diffstat (limited to 'absl/strings/internal/escaping.h')
-rw-r--r--absl/strings/internal/escaping.h16
1 files changed, 7 insertions, 9 deletions
diff --git a/absl/strings/internal/escaping.h b/absl/strings/internal/escaping.h
index 6a9ce602..b04033ff 100644
--- a/absl/strings/internal/escaping.h
+++ b/absl/strings/internal/escaping.h
@@ -25,19 +25,17 @@ namespace strings_internal {
ABSL_CONST_INIT extern const char kBase64Chars[];
-// Calculates how long a string will be when it is base64 encoded given its
-// length and whether or not the result should be padded.
+// Calculates the length of a Base64 encoding (RFC 4648) of a string of length
+// `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);
-// 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. Returns the length of `dest`.
+// Base64-encodes `src` using the alphabet provided in `base64` (which
+// determines whether to do web-safe encoding or not) and writes the result to
+// `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 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>
void Base64EscapeInternal(const unsigned char* src, size_t szsrc, String* dest,
bool do_padding, const char* base64_chars) {