Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An encoder for base 64 #2028

Merged
merged 6 commits into from
Dec 16, 2018
Merged

An encoder for base 64 #2028

merged 6 commits into from
Dec 16, 2018

Conversation

pleroy
Copy link
Member

@pleroy pleroy commented Dec 15, 2018

No description provided.

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
base/base64.hpp Outdated Show resolved Hide resolved
void principia::base::internal_base64::Base64Encoder<null_terminated>::Encode(
Array<std::uint8_t const> input,
Array<char> output) {
std::string_view const input_view(reinterpret_cast<const char*>(input.data),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have string_view on mac?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non lo so. There is an absl::string_view. We'll switch to that if Linux/macOS doesn't have the std version.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can always summon the most boring kind of UB by

#if OS_MACOSX
namespace std {
using absl::string_view;
}  // namespace std
#endif

base/base64_body.hpp Outdated Show resolved Hide resolved
absl::WebSafeBase64Escape(input_view, &output_string);
std::memcpy(output.data, output_string.c_str(), output_string.size());
if constexpr (null_terminated) {
output.data[output_size.size()] = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just memcpy one more byte, std::string has null-terminated storage.

Sorry, something went wrong.

base/base32768.hpp Outdated Show resolved Hide resolved
@eggrobin eggrobin added the LGTM label Dec 15, 2018
@pleroy pleroy merged commit dda9bf9 into mockingbirdnest:master Dec 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants