diff --git a/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp b/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp index b3546af3ec..d739cedf33 100644 --- a/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp @@ -452,7 +452,6 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::pad_end) return pad_string(global_object, move(string), PadPlacement::End); } -static constexpr Utf8View whitespace_characters = Utf8View("\x09\x0A\x0B\x0C\x0D\x20\xC2\xA0\xE1\x9A\x80\xE2\x80\x80\xE2\x80\x81\xE2\x80\x82\xE2\x80\x83\xE2\x80\x84\xE2\x80\x85\xE2\x80\x86\xE2\x80\x87\xE2\x80\x88\xE2\x80\x89\xE2\x80\x8A\xE2\x80\xAF\xE2\x81\x9F\xE3\x80\x80\xE2\x80\xA8\xE2\x80\xA9\xEF\xBB\xBF"sv); ThrowCompletionOr trim_string(GlobalObject& global_object, Value input_value, TrimMode where) { // 1. Let str be ? RequireObjectCoercible(string). diff --git a/Userland/Libraries/LibJS/Runtime/StringPrototype.h b/Userland/Libraries/LibJS/Runtime/StringPrototype.h index 1a3a7371a4..437fe196d7 100644 --- a/Userland/Libraries/LibJS/Runtime/StringPrototype.h +++ b/Userland/Libraries/LibJS/Runtime/StringPrototype.h @@ -17,6 +17,7 @@ struct CodePoint { }; CodePoint code_point_at(Utf16View const& string, size_t position); +static constexpr Utf8View whitespace_characters = Utf8View("\x09\x0A\x0B\x0C\x0D\x20\xC2\xA0\xE1\x9A\x80\xE2\x80\x80\xE2\x80\x81\xE2\x80\x82\xE2\x80\x83\xE2\x80\x84\xE2\x80\x85\xE2\x80\x86\xE2\x80\x87\xE2\x80\x88\xE2\x80\x89\xE2\x80\x8A\xE2\x80\xAF\xE2\x81\x9F\xE3\x80\x80\xE2\x80\xA8\xE2\x80\xA9\xEF\xBB\xBF"sv); ThrowCompletionOr trim_string(GlobalObject&, Value string, TrimMode where); class StringPrototype final : public StringObject { diff --git a/Userland/Libraries/LibJS/Runtime/Value.cpp b/Userland/Libraries/LibJS/Runtime/Value.cpp index 017144fdd9..06fdd8c0c7 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.cpp +++ b/Userland/Libraries/LibJS/Runtime/Value.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -476,7 +477,7 @@ ThrowCompletionOr Value::to_number(GlobalObject& global_object) const case Type::Double: return *this; case Type::String: { - auto string = as_string().string().trim_whitespace(); + String string = Utf8View(as_string().string()).trim(whitespace_characters, AK::TrimMode::Both).as_string(); if (string.is_empty()) return Value(0); if (string == "Infinity" || string == "+Infinity")