zhjwpku commented on code in PR #646:
URL: https://github.com/apache/iceberg-cpp/pull/646#discussion_r3213346182
##########
src/iceberg/util/transform_util.cc:
##########
@@ -283,4 +283,76 @@ std::string TransformUtil::Base64Encode(std::string_view
str_to_encode) {
return encoded;
}
+namespace {
+
+// Shared base64 decode logic. The decode table maps ASCII char → 6-bit value.
+// 0xFF means invalid character.
+std::string Base64DecodeWithTable(std::string_view input,
+ const std::array<uint8_t, 256>& table) {
+ // Strip trailing padding
+ while (!input.empty() && input.back() == '=') {
+ input.remove_suffix(1);
+ }
+ if (input.empty()) {
+ return {};
+ }
+
+ std::string output;
+ output.reserve((input.size() * 3) / 4);
+
+ uint32_t buffer = 0;
+ int bits_collected = 0;
+
+ for (char c : input) {
+ uint8_t val = table[static_cast<uint8_t>(c)];
+ if (val == 0xFF) {
+ return {}; // Invalid character
Review Comment:
Should we return Result<std::string> so that we know input is just empty or
invalid?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]