mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-29 19:10:26 +00:00
f590cd1850
This lets us propagate the reason why it failed up to the caller. :^)
35 lines
672 B
C++
35 lines
672 B
C++
/*
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/ByteBuffer.h>
|
|
#include <AK/Error.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;
|
|
}
|
|
|
|
ErrorOr<ByteBuffer> decode_hex(StringView);
|
|
|
|
String encode_hex(ReadonlyBytes);
|
|
|
|
}
|
|
|
|
using AK::decode_hex;
|
|
using AK::decode_hex_digit;
|
|
using AK::encode_hex;
|