From 87ac38c78b49af94a70e3150e7e1b8a58ac6bd40 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Sat, 1 Oct 2022 18:07:51 +0100 Subject: [PATCH] LibWeb: Add is_ascii_whitespace() function This matches the Infra spec's definition of 'ASCII whitespace', and we can at last stop using AK::is_ascii_space(), which has a different idea about what 'whitespace' means. --- .../Libraries/LibWeb/Infra/CharacterTypes.h | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Userland/Libraries/LibWeb/Infra/CharacterTypes.h diff --git a/Userland/Libraries/LibWeb/Infra/CharacterTypes.h b/Userland/Libraries/LibWeb/Infra/CharacterTypes.h new file mode 100644 index 0000000000..e73ff470e9 --- /dev/null +++ b/Userland/Libraries/LibWeb/Infra/CharacterTypes.h @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2022, Linus Groh + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include + +namespace Web::Infra { + +// https://infra.spec.whatwg.org/#ascii-whitespace +constexpr bool is_ascii_whitespace(u32 code_point) +{ + // ASCII whitespace is U+0009 TAB, U+000A LF, U+000C FF, U+000D CR, or U+0020 SPACE. + return code_point == '\t' || code_point == '\n' || code_point == '\f' || code_point == '\r' || code_point == ' '; +} + +}