1 |
|
2 | import { BinaryBuffer, BinaryBufferReadableStream, BinaryBufferReadable } from './buffer';
|
3 | import { UTF8_with_bom, UTF16be, UTF16le } from './encodings';
|
4 | import { ReadableStream, Readable } from './stream';
|
5 | export interface ResourceEncoding {
|
6 | encoding: string;
|
7 | hasBOM: boolean;
|
8 | }
|
9 | export interface DetectedEncoding {
|
10 | encoding?: string;
|
11 | seemsBinary?: boolean;
|
12 | }
|
13 | export interface DecodeStreamOptions {
|
14 | guessEncoding?: boolean;
|
15 | minBytesRequiredForDetection?: number;
|
16 | overwriteEncoding(detectedEncoding: string | undefined): Promise<string>;
|
17 | }
|
18 | export interface DecodeStreamResult {
|
19 | stream: ReadableStream<string>;
|
20 | detected: DetectedEncoding;
|
21 | }
|
22 | export declare class EncodingService {
|
23 | encode(value: string, options?: ResourceEncoding): BinaryBuffer;
|
24 | decode(value: BinaryBuffer, encoding?: string): string;
|
25 | exists(encoding: string): boolean;
|
26 | toIconvEncoding(encoding?: string): string;
|
27 | toResourceEncoding(encoding: string, options: {
|
28 | overwriteEncoding?: boolean;
|
29 | read: (length: number) => Promise<Uint8Array>;
|
30 | }): Promise<ResourceEncoding>;
|
31 | detectEncoding(data: BinaryBuffer, autoGuessEncoding?: boolean): Promise<DetectedEncoding>;
|
32 | protected detectEncodingByBOMFromBuffer(buffer: Buffer, bytesRead: number): typeof UTF8_with_bom | typeof UTF16le | typeof UTF16be | undefined;
|
33 | protected guessEncodingByBuffer(buffer: Buffer): Promise<string | undefined>;
|
34 | decodeStream(source: BinaryBufferReadableStream, options: DecodeStreamOptions): Promise<DecodeStreamResult>;
|
35 | encodeStream(value: string | Readable<string>, options?: ResourceEncoding): Promise<BinaryBuffer | BinaryBufferReadable>;
|
36 | encodeStream(value?: string | Readable<string>, options?: ResourceEncoding): Promise<BinaryBuffer | BinaryBufferReadable | undefined>;
|
37 | }
|
38 |
|
\ | No newline at end of file |