Files
shaka-packager/packager/utils/hex_parser.cc
Niklas Korz 27a1d71e3d
Some checks failed
Update Issues / update-issues (push) Has been cancelled
Release / Settings (push) Has been cancelled
Release / release (push) Has been cancelled
Release / Compute latest release flag (push) Has been cancelled
Release / Update docs (push) Has been cancelled
Release / Build (push) Has been cancelled
Release / Update docker image (push) Has been cancelled
Release / Artifacts (push) Has been cancelled
Release / Update NPM (push) Has been cancelled
fix(deps): update abseil-cpp to 20260107.1, protobuf to 33.5 (#1553)
All deprecations have been addressed in this PR and Protobuf has been
updated to 33.5 as older versions lead to build failures on Linux with
this abseil-cpp version.
2026-03-17 20:48:13 -07:00

34 lines
1.0 KiB
C++

// Copyright 2022 Google LLC. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#include <packager/utils/hex_parser.h>
#include <absl/strings/escaping.h>
#include <absl/types/span.h>
namespace shaka {
bool ValidHexStringToBytes(const std::string& hex,
std::vector<uint8_t>* bytes) {
std::string raw;
if (!ValidHexStringToBytes(hex, &raw))
return false;
absl::string_view str_view(raw);
absl::Span<const uint8_t> span(
reinterpret_cast<const uint8_t*>(str_view.data()), str_view.size());
*bytes = std::vector<uint8_t>(span.begin(), span.end());
return true;
}
bool ValidHexStringToBytes(const std::string& hex, std::string* bytes) {
// absl::HexStringToBytes validates the input during processing and
// aborts on invalid data, leaving "bytes" in an unspecified state.
return absl::HexStringToBytes(hex, bytes);
}
} // namespace shaka