aboutsummaryrefslogtreecommitdiff
path: root/absl/strings/internal/escaping.h
diff options
context:
space:
mode:
authorBenjamin Barenblat <bbaren@google.com>2023-05-08 12:51:08 -0400
committerBenjamin Barenblat <bbaren@google.com>2023-05-08 12:51:08 -0400
commitc15cec707b1c7d847e59d2db4d0b82b711a7ee6d (patch)
tree79f448d5bbc8cf52917b0b091f0e1ab60a419c85 /absl/strings/internal/escaping.h
parentf4f2c1da90c4e6a0683c4e66c0268baa1b79cdf3 (diff)
parentc2435f8342c2d0ed8101cb43adfd605fdc52dca2 (diff)
downloadabseil-c15cec707b1c7d847e59d2db4d0b82b711a7ee6d.tar.gz
abseil-c15cec707b1c7d847e59d2db4d0b82b711a7ee6d.tar.bz2
abseil-c15cec707b1c7d847e59d2db4d0b82b711a7ee6d.zip
Merge new upstream LTS 20230125.3
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) {