(input = '')
| 93 | } |
| 94 | |
| 95 | public encode(input = ''): Uint8Array { |
| 96 | // 0xc0 => 0b11000000; 0xff => 0b11111111; 0xc0-0xff => 0b11xxxxxx |
| 97 | // 0x80 => 0b10000000; 0xbf => 0b10111111; 0x80-0xbf => 0b10xxxxxx |
| 98 | const encodedString = input === undefined ? '' : ('' + input).replace(/[\x80-\uD7ff\uDC00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]?/g, encoderReplacer); |
| 99 | const len = encodedString.length | 0, |
| 100 | result = new Uint8Array(len); |
| 101 | for (let i = 0; i < len; i = (i + 1) | 0) { |
| 102 | result[i] = encodedString.charCodeAt(i); |
| 103 | } |
| 104 | |
| 105 | return result; |
| 106 | } |
| 107 | |
| 108 | public toString() { |
| 109 | return '[object TextEncoder]'; |
no test coverage detected