(bytes: Uint8Array, offset: number, size: number)
| 221 | ?.prototype?.utf8Slice |
| 222 | |
| 223 | const decodeUtf8 = (bytes: Uint8Array, offset: number, size: number): string => { |
| 224 | if (size <= asciiDecodeLimit) { |
| 225 | let text = "" |
| 226 | let index = 0 |
| 227 | for (; index < size; index++) { |
| 228 | const code = bytes[offset + index] |
| 229 | if (code > 0x7f) break |
| 230 | text += String.fromCharCode(code) |
| 231 | } |
| 232 | if (index === size) return text |
| 233 | } |
| 234 | if (utf8Slice !== undefined) { |
| 235 | const text = utf8Slice.call(bytes, offset, offset + size) |
| 236 | if (text.indexOf("\ufffd") === -1) return text |
| 237 | } |
| 238 | try { |
| 239 | return textDecoder.decode(region(bytes, offset, size)) |
| 240 | } catch { |
| 241 | return fail("Invalid UTF-8 in text value") |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | /** |
| 246 | * The UTF-8 fallback for an OID with no codec. PostgreSQL's text output never |
no test coverage detected