Serenity Operating System
1/*
2 * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
3 *
4 * SPDX-License-Identifier: BSD-2-Clause
5 */
6
7#pragma once
8
9#include <AK/Forward.h>
10#include <AK/NonnullRefPtr.h>
11#include <AK/RefCounted.h>
12#include <LibJS/Forward.h>
13#include <LibWeb/Bindings/PlatformObject.h>
14#include <LibWeb/Forward.h>
15
16namespace Web::Encoding {
17
18// https://encoding.spec.whatwg.org/#textencoder
19class TextEncoder final : public Bindings::PlatformObject {
20 WEB_PLATFORM_OBJECT(TextEncoder, Bindings::PlatformObject);
21
22public:
23 static WebIDL::ExceptionOr<JS::NonnullGCPtr<TextEncoder>> construct_impl(JS::Realm&);
24
25 virtual ~TextEncoder() override;
26
27 JS::Uint8Array* encode(DeprecatedString const& input) const;
28
29 static DeprecatedFlyString const& encoding();
30
31protected:
32 // https://encoding.spec.whatwg.org/#dom-textencoder
33 explicit TextEncoder(JS::Realm&);
34
35 virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
36};
37
38}