TextEncoder.h 885 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Forward.h>
  8. #include <AK/NonnullRefPtr.h>
  9. #include <AK/RefCounted.h>
  10. #include <LibJS/Forward.h>
  11. #include <LibWeb/Bindings/Wrappable.h>
  12. #include <LibWeb/Forward.h>
  13. namespace Web::Encoding {
  14. // https://encoding.spec.whatwg.org/#textencoder
  15. class TextEncoder final : public Bindings::PlatformObject {
  16. WEB_PLATFORM_OBJECT(TextEncoder, Bindings::PlatformObject);
  17. public:
  18. static JS::NonnullGCPtr<TextEncoder> create_with_global_object(HTML::Window&);
  19. virtual ~TextEncoder() override;
  20. JS::Uint8Array* encode(String const& input) const;
  21. static FlyString const& encoding();
  22. protected:
  23. // https://encoding.spec.whatwg.org/#dom-textencoder
  24. explicit TextEncoder(HTML::Window&);
  25. };
  26. }
  27. WRAPPER_HACK(TextEncoder, Web::Encoding)