UNPKG

react-native-encoding-api

Version:

A React Native package for handling text encoding and decoding

28 lines (27 loc) 833 B
/** * A drop-in replacement for the native TextEncoder/TextDecoder that's missing in React Native. * Provides the exact same API and behavior as the Web API's TextEncoder/TextDecoder. */ export declare class TextEncoder { /** * Encodes a string into UTF-8 bytes * @param text The text to encode * @returns A Uint8Array containing the UTF-8 encoded bytes */ encode(text: string): Uint8Array; } export declare class TextDecoder { private encoding; private fatal; private ignoreBOM; constructor(encoding?: string, options?: { fatal?: boolean; ignoreBOM?: boolean; }); /** * Decodes a Uint8Array into a string using UTF-8 encoding * @param bytes The input array to decode * @returns The decoded string */ decode(bytes: Uint8Array): string; }