1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/.
6 * The origin of this IDL file is
7 * http://encoding.spec.whatwg.org/#interface-textencoder
10 interface mixin TextEncoderCommon {
12 * This is DOMString in the spec, but the value is always ASCII
13 * and short. By declaring this as ByteString, we get the same
14 * end result (storage as inline Latin1 string in SpiderMonkey)
15 * with fewer conversions.
18 readonly attribute ByteString encoding;
21 dictionary TextEncoderEncodeIntoResult {
22 unsigned long long read;
23 unsigned long long written;
26 [Exposed=(Window,Worker)]
27 interface TextEncoder {
31 * This is spec-wise USVString but marking it as UTF8String as an
32 * optimization. (The SpiderMonkey-provided conversion to UTF-8 takes care of
33 * replacing lone surrogates with the REPLACEMENT CHARACTER, so the
34 * observable behavior of USVString is matched.)
37 Uint8Array encode(optional UTF8String input = "");
40 * The same comment about UTF8String as above applies here with JSString.
42 * We use JSString because we don't want to encode the full string, just as
43 * much as the capacity of the Uint8Array.
46 TextEncoderEncodeIntoResult encodeInto(JSString source, Uint8Array destination);
48 TextEncoder includes TextEncoderCommon;