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:
parent
eae9cb2b02
commit
87ac38c78b
1 changed files with 20 additions and 0 deletions
20
Userland/Libraries/LibWeb/Infra/CharacterTypes.h
Normal file
20
Userland/Libraries/LibWeb/Infra/CharacterTypes.h
Normal 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 == ' ';
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue