ladybird/AK/Hex.h
Brian Gianforcaro 1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00

36 lines
683 B
C++

/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/ByteBuffer.h>
#include <AK/Optional.h>
#include <AK/String.h>
#include <AK/StringView.h>
namespace AK {
constexpr u8 decode_hex_digit(char digit)
{
if (digit >= '0' && digit <= '9')
return digit - '0';
if (digit >= 'a' && digit <= 'f')
return 10 + (digit - 'a');
if (digit >= 'A' && digit <= 'F')
return 10 + (digit - 'A');
return 255;
}
Optional<ByteBuffer> decode_hex(const StringView&);
String encode_hex(ReadonlyBytes);
}
using AK::decode_hex;
using AK::decode_hex_digit;
using AK::encode_hex;