1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 05:47:35 +00:00

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.
This commit is contained in:
Linus Groh 2022-10-01 18:07:51 +01:00 committed by Andreas Kling
parent eae9cb2b02
commit 87ac38c78b

View file

@ -0,0 +1,20 @@
/*
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Types.h>
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 == ' ';
}
}