UNPKG

@adguard/agtree

Version:
19 lines (18 loc) 746 B
/** * @file Utility for encoding strings to byte sequences. */ export interface TextEncoderPolyfillResult { readonly written: number; readonly read: number; } /** * Encodes an UTF-8 string into a byte sequence according to the WHATWG spec. * * @param str String to encode. * @param buffer Buffer to write the encoded bytes to. * @returns Number of bytes written to the buffer. * @see {@link https://encoding.spec.whatwg.org/#utf-8-encoder} * @note Bytes written maybe larger than the string length, but never smaller. * For example, the string '你好' has a length of 2, but its byte representation has a length of 6. */ export declare const encodeIntoPolyfill: (str: string, buffer: Uint8Array) => TextEncoderPolyfillResult;