* Given a codepoint, return the name of the script or script family * it is from, or null if it is not part of a known block
(codepoint)
| 530 | */ |
| 531 | |
| 532 | function scriptFromCodepoint(codepoint) { |
| 533 | for (let i = 0; i < scriptData.length; i++) { |
| 534 | const script = scriptData[i]; |
| 535 | |
| 536 | for (let i = 0; i < script.blocks.length; i++) { |
| 537 | const block = script.blocks[i]; |
| 538 | |
| 539 | if (codepoint >= block[0] && codepoint <= block[1]) { |
| 540 | return script.name; |
| 541 | } |
| 542 | } |
| 543 | } |
| 544 | |
| 545 | return null; |
| 546 | } |
| 547 | /** |
| 548 | * A flattened version of all the supported blocks in a single array. |
| 549 | * This is an optimization to make supportedCodepoint() fast. |