/** * Text encoding utilities * Handles conversion between strings and byte arrays with various encodings */ /** * Encoding configuration options */ export interface EncodingConfig { /** Whether to show warnings for unsupported encodings */ showWarnings?: boolean; } /** * Text encoding utility class * * Provides encoding services for converting strings to byte arrays. * Currently supports UTF-8 natively. GBK support can be added via custom encoding * functions passed to `encode()` and `decode()`. * * @example * ```typescript * // Configure encoding to disable warnings * Encoding.configure({ showWarnings: false }); * * const bytes = Encoding.encode('Hello World', 'UTF-8'); * const gbkBytes = Encoding.encode('你好世界', 'GBK'); * ``` */ export declare class Encoding { private static utf8Encoder; private static warningShown; private static config; /** * Configures the encoding utility * * @param config - Configuration options * * @example * ```typescript * Encoding.configure({ * showWarnings: false * }); * ``` */ static configure(config: Partial): void; /** * Encodes a string to a Uint8Array using the specified encoding * * @param text - Text to encode * @param encoding - Target encoding (default: 'GBK') * @returns Encoded bytes * * @remarks * Note: Native TextEncoder only supports UTF-8. * For GBK encoding, a third-party library or polyfill is recommended. * Currently falls back to UTF-8 with a warning (configurable). * * @example * ```typescript * // UTF-8 encoding * const utf8 = Encoding.encode('Hello', 'UTF-8'); * * // GBK encoding (currently falls back to UTF-8) * const gbk = Encoding.encode('你好', 'GBK'); * ``` */ static encode(text: string, encoding?: string): Uint8Array; /** * Checks if an encoding is supported * * @param encoding - Encoding name to check * @returns True if supported, false otherwise * * @example * ```typescript * if (Encoding.isSupported('GBK')) { * console.log('GBK is supported'); * } * ``` */ static isSupported(encoding: string): boolean; }