UNPKG

@forgesworn/qr

Version:

Dependency-free QR code encoder and decoder for TypeScript, browsers, workers and Node, with optional WebAssembly and tracked camera scanning.

44 lines (43 loc) • 2.35 kB
/** True when `bytes` is entirely well-formed UTF-8. */ export declare function isUtf8(bytes: Uint8Array): boolean; /** Decodes UTF-8, replacing each ill-formed byte with U+FFFD. */ export declare function fromUtf8(bytes: Uint8Array): string; /** * Text for bytes under an ECI this platform cannot read, or one that names * no set this decoder knows: never a guess at another character set. Under * a single-byte set the ASCII bytes are certain and are kept; every other * byte, and every byte under any other ECI, is U+FFFD. */ export declare function unread(eci: number, bytes: Uint8Array): string; /** * Text for `bytes` under an ECI assignment other than 1, 3 and 26, or * undefined when the platform lacks the character set (the caller then uses * unread()). Malformed input becomes U+FFFD. */ export declare function fromEci(eci: number, bytes: Uint8Array): string | undefined; /** * The text of one kanji-mode character, given its Shift_JIS bytes: what the * platform makes of them, or U+FFFD alone if it makes nothing clean of them or * has no Shift_JIS. */ export declare function kanjiText(sjis: number): string; /** * The text of one hanzi-mode character, given its GB2312 lead and low bytes: what the * platform's GB 18030 makes of them, or U+FFFD alone if the platform has none. * Undefined, rejecting the symbol, when the pair is outside the GB2312 rows * (A1-A9 and B0-F7, cells A1-FE) or names no character: the platform answers * with U+FFFD or a private-use character for an empty cell. */ export declare function hanziText(lead: number, low: number): string | undefined; /** * Whether bytes that are not valid UTF-8 and carry no ECI look like Shift_JIS * rather than Latin-1. Scanning left to right, a byte below 0x80 is skipped; * 0xA1 to 0xDF is a half-width katakana; 0x81 to 0x9F or 0xE0 to 0xEF followed * by 0x40 to 0x7E or 0x80 to 0xFC is a double-byte character; anything else of * 0x80 or more (0x80, 0xA0, 0xF0 to 0xFF, or a lead without a trail) rules * Shift_JIS out. With none ruled out, it is Shift_JIS if the bytes hold three * katakana in a row, three double-byte characters in a row, or a double-byte * character whose lead is 0x81 to 0x9F (a control in Latin-1, so never text * there); otherwise it is Latin-1. */ export declare function looksShiftJis(bytes: Uint8Array): boolean;