( input: string, pos: number, lineStart: number, curLine: number, throwOnInvalid: boolean, errors: CodePointErrorHandlers, )
| 404 | }; |
| 405 | |
| 406 | export function readCodePoint( |
| 407 | input: string, |
| 408 | pos: number, |
| 409 | lineStart: number, |
| 410 | curLine: number, |
| 411 | throwOnInvalid: boolean, |
| 412 | errors: CodePointErrorHandlers, |
| 413 | ) { |
| 414 | const ch = input.charCodeAt(pos); |
| 415 | let code; |
| 416 | |
| 417 | if (ch === charCodes.leftCurlyBrace) { |
| 418 | ++pos; |
| 419 | ({ code, pos } = readHexChar( |
| 420 | input, |
| 421 | pos, |
| 422 | lineStart, |
| 423 | curLine, |
| 424 | input.indexOf("}", pos) - pos, |
| 425 | true, |
| 426 | throwOnInvalid, |
| 427 | errors, |
| 428 | )); |
| 429 | ++pos; |
| 430 | if (code !== null && code > 0x10ffff) { |
| 431 | if (throwOnInvalid) { |
| 432 | errors.invalidCodePoint(pos, lineStart, curLine); |
| 433 | } else { |
| 434 | return { code: null, pos }; |
| 435 | } |
| 436 | } |
| 437 | } else { |
| 438 | ({ code, pos } = readHexChar( |
| 439 | input, |
| 440 | pos, |
| 441 | lineStart, |
| 442 | curLine, |
| 443 | 4, |
| 444 | false, |
| 445 | throwOnInvalid, |
| 446 | errors, |
| 447 | )); |
| 448 | } |
| 449 | return { code, pos }; |
| 450 | } |
no test coverage detected