blob: 4443e3d6cb865c0d58355c17f70450667cdcbb69 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
/*
* Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Assertions.h>
#include <AK/DeprecatedString.h>
namespace Web::CSS {
// https://www.w3.org/TR/css-syntax-3/#urange-syntax
class UnicodeRange {
public:
UnicodeRange(u32 min_code_point, u32 max_code_point)
: m_min_code_point(min_code_point)
, m_max_code_point(max_code_point)
{
VERIFY(min_code_point <= max_code_point);
}
u32 min_code_point() const { return m_min_code_point; }
u32 max_code_point() const { return m_max_code_point; }
bool contains(u32 code_point) const
{
return m_min_code_point <= code_point && code_point <= m_max_code_point;
}
DeprecatedString to_deprecated_string() const
{
if (m_min_code_point == m_max_code_point)
return DeprecatedString::formatted("U+{:x}", m_min_code_point);
return DeprecatedString::formatted("U+{:x}-{:x}", m_min_code_point, m_max_code_point);
}
private:
u32 m_min_code_point;
u32 m_max_code_point;
};
}
|