User:Erutuon/scripts/scriptRecognition.js

/* A function to convert codepoint to script code, as well as a function that counts how many characters belong to each script, and another that does the same except it excludes characters from scripts that are not used by a natural language.

// /* globals $ */

"use strict";

const ignoredScripts = [ "Zinh", "Zmth", "Zsym", "Zsye", "Zxxx", "Zyyy", "Zzzz" ];

// From Module:Language/scripts/codepoints. const individual = { 0x00020: "Zyyy", 0x00024: "Zyyy", 0x00028: "Zyyy", 0x00029: "Zyyy", 0x0002A: "Zyyy", 0x0002B: "Zyyy", 0x0002C: "Zyyy", 0x0002D: "Zyyy", 0x0005B: "Zyyy", 0x0005C: "Zyyy", 0x0005D: "Zyyy", 0x0005E: "Zyyy", 0x0005F: "Zyyy", 0x00060: "Zyyy", 0x0007B: "Zyyy", 0x0007C: "Zyyy", 0x0007D: "Zyyy", 0x0007E: "Zyyy", 0x000A0: "Zyyy", 0x000A1: "Zyyy", 0x000A6: "Zyyy", 0x000A7: "Zyyy", 0x000A8: "Zyyy", 0x000A9: "Zyyy", 0x000AA: "Latn", 0x000AB: "Zyyy", 0x000AC: "Zyyy", 0x000AD: "Zyyy", 0x000AE: "Zyyy", 0x000AF: "Zyyy", 0x000B0: "Zyyy", 0x000B1: "Zyyy", 0x000B4: "Zyyy", 0x000B5: "Zyyy", 0x000B8: "Zyyy", 0x000B9: "Zyyy", 0x000BA: "Latn", 0x000BB: "Zyyy", 0x000BF: "Zyyy", 0x000D7: "Zyyy", 0x000F7: "Zyyy", 0x001BB: "Latn", 0x00294: "Latn", 0x002EC: "Zyyy", 0x002ED: "Zyyy", 0x002EE: "Zyyy", 0x00374: "Zyyy", 0x00375: "Grek", 0x0037A: "Grek", 0x0037E: "Zyyy", 0x0037F: "Grek", 0x00384: "Grek", 0x00385: "Zyyy", 0x00386: "Grek", 0x00387: "Zyyy", 0x0038C: "Grek", 0x003F6: "Grek", 0x00482: "Cyrl", 0x00487: "Cyrl", 0x00559: "Armn", 0x00589: "Zyyy", 0x0058A: "Armn", 0x0058F: "Armn", 0x005BE: "Hebr", 0x005BF: "Hebr", 0x005C0: "Hebr", 0x005C3: "Hebr", 0x005C6: "Hebr", 0x005C7: "Hebr", 0x00605: "Zyyy", 0x0060B: "Arab", 0x0060C: "Zyyy", 0x0060D: "Arab", 0x0061B: "Zyyy", 0x0061C: "Arab", 0x0061E: "Arab", 0x0061F: "Zyyy", 0x00640: "Zyyy", 0x00670: "Zinh", 0x006D4: "Arab", 0x006D5: "Arab", 0x006DD: "Zyyy", 0x006DE: "Arab", 0x006E9: "Arab", 0x006FF: "Arab", 0x0070F: "Syrc", 0x00710: "Syrc", 0x00711: "Syrc", 0x007B1: "Thaa", 0x007F6: "Nkoo", 0x007FA: "Nkoo", 0x0081A: "Samr", 0x00824: "Samr", 0x00828: "Samr", 0x0085E: "Mand", 0x008E2: "Zyyy", 0x00903: "Deva", 0x0093A: "Deva", 0x0093B: "Deva", 0x0093C: "Deva", 0x0093D: "Deva", 0x0094D: "Deva", 0x00950: "Deva", 0x00970: "Deva", 0x00971: "Deva", 0x00980: "Beng", 0x00981: "Beng", 0x009B2: "Beng", 0x009BC: "Beng", 0x009BD: "Beng", 0x009CD: "Beng", 0x009CE: "Beng", 0x009D7: "Beng", 0x009FA: "Beng", 0x009FB: "Beng", 0x009FC: "Beng", 0x009FD: "Beng", 0x00A03: "Guru", 0x00A3C: "Guru", 0x00A51: "Guru", 0x00A5E: "Guru", 0x00A75: "Guru", 0x00A83: "Gujr", 0x00ABC: "Gujr", 0x00ABD: "Gujr", 0x00AC9: "Gujr", 0x00ACD: "Gujr", 0x00AD0: "Gujr", 0x00AF0: "Gujr", 0x00AF1: "Gujr", 0x00AF9: "Gujr", 0x00B01: "Orya", 0x00B3C: "Orya", 0x00B3D: "Orya", 0x00B3E: "Orya", 0x00B3F: "Orya", 0x00B40: "Orya", 0x00B4D: "Orya", 0x00B56: "Orya", 0x00B57: "Orya", 0x00B70: "Orya", 0x00B71: "Orya", 0x00B82: "Taml", 0x00B83: "Taml", 0x00B9C: "Taml", 0x00BC0: "Taml", 0x00BCD: "Taml", 0x00BD0: "Taml", 0x00BD7: "Taml", 0x00BF9: "Taml", 0x00BFA: "Taml", 0x00C00: "Telu", 0x00C3D: "Telu", 0x00C7F: "Telu", 0x00C80: "Knda", 0x00C81: "Knda", 0x00CBC: "Knda", 0x00CBD: "Knda", 0x00CBE: "Knda", 0x00CBF: "Knda", 0x00CC6: "Knda", 0x00CDE: "Knda", 0x00D3D: "Mlym", 0x00D4D: "Mlym", 0x00D4E: "Mlym", 0x00D4F: "Mlym", 0x00D57: "Mlym", 0x00D79: "Mlym", 0x00DBD: "Sinh", 0x00DCA: "Sinh", 0x00DD6: "Sinh", 0x00DF4: "Sinh", 0x00E31: "Thai", 0x00E3F: "Zyyy", 0x00E46: "Thai", 0x00E4F: "Thai", 0x00E84: "Laoo", 0x00E8A: "Laoo", 0x00E8D: "Laoo", 0x00EA5: "Laoo", 0x00EA7: "Laoo", 0x00EB1: "Laoo", 0x00EBD: "Laoo", 0x00EC6: "Laoo", 0x00F00: "Tibt", 0x00F13: "Tibt", 0x00F14: "Tibt", 0x00F34: "Tibt", 0x00F35: "Tibt", 0x00F36: "Tibt", 0x00F37: "Tibt", 0x00F38: "Tibt", 0x00F39: "Tibt", 0x00F3A: "Tibt", 0x00F3B: "Tibt", 0x00F3C: "Tibt", 0x00F3D: "Tibt", 0x00F7F: "Tibt", 0x00F85: "Tibt", 0x00FC6: "Tibt", 0x01031: "Mymr", 0x01038: "Mymr", 0x0103F: "Mymr", 0x01061: "Mymr", 0x01082: "Mymr", 0x0108D: "Mymr", 0x0108E: "Mymr", 0x0108F: "Mymr", 0x0109D: "Mymr", 0x010C7: "Geor", 0x010CD: "Geor", 0x010FB: "Zyyy", 0x010FC: "Geor", 0x01258: "Ethi", 0x012C0: "Ethi", 0x01400: "Cans", 0x01680: "Ogam", 0x0169B: "Ogam", 0x0169C: "Ogam", 0x017B6: "Khmr", 0x017C6: "Khmr", 0x017D7: "Khmr", 0x017DB: "Khmr", 0x017DC: "Khmr", 0x017DD: "Khmr", 0x01804: "Mong", 0x01805: "Zyyy", 0x01806: "Mong", 0x0180E: "Mong", 0x01843: "Mong", 0x018A9: "Mong", 0x018AA: "Mong", 0x01932: "Limb", 0x01940: "Limb", 0x019DA: "Talu", 0x01A1B: "Bugi", 0x01A55: "Tavt", 0x01A56: "Tavt", 0x01A57: "Tavt", 0x01A60: "Tavt", 0x01A61: "Tavt", 0x01A62: "Tavt", 0x01A7F: "Tavt", 0x01AA7: "Tavt", 0x01ABE: "Zinh", 0x01B04: "Bali", 0x01B34: "Bali", 0x01B35: "Bali", 0x01B3B: "Bali", 0x01B3C: "Bali", 0x01B42: "Bali", 0x01B82: "Sund", 0x01BA1: "Sund", 0x01BAA: "Sund", 0x01BE6: "Batk", 0x01BE7: "Batk", 0x01BED: "Batk", 0x01BEE: "Batk", 0x01CD3: "Zyyy", 0x01CE1: "Zyyy", 0x01CED: "Zinh", 0x01CF4: "Zinh", 0x01CF7: "Zyyy", 0x01D2B: "Cyrl", 0x01D78: "Cyrl", 0x01DBF: "Grek", 0x01F59: "Grek", 0x01F5B: "Grek", 0x01F5D: "Grek", 0x01FBD: "Grek", 0x01FBE: "Grek", 0x0200B: "Zyyy", 0x02018: "Zyyy", 0x02019: "Zyyy", 0x0201A: "Zyyy", 0x0201D: "Zyyy", 0x0201E: "Zyyy", 0x0201F: "Zyyy", 0x02028: "Zyyy", 0x02029: "Zyyy", 0x0202F: "Zyyy", 0x02039: "Zyyy", 0x0203A: "Zyyy", 0x02044: "Zyyy", 0x02045: "Zyyy", 0x02046: "Zyyy", 0x02052: "Zyyy", 0x02053: "Zyyy", 0x02054: "Zyyy", 0x0205F: "Zyyy", 0x02070: "Zyyy", 0x02071: "Latn", 0x0207D: "Zyyy", 0x0207E: "Zyyy", 0x0207F: "Latn", 0x0208D: "Zyyy", 0x0208E: "Zyyy", 0x020E1: "Zinh", 0x02102: "Zyyy", 0x02107: "Zyyy", 0x02114: "Zyyy", 0x02115: "Zyyy", 0x02118: "Zyyy", 0x02124: "Zyyy", 0x02125: "Zyyy", 0x02126: "Grek", 0x02127: "Zyyy", 0x02128: "Zyyy", 0x02129: "Zyyy", 0x0212E: "Zyyy", 0x02132: "Latn", 0x02139: "Zyyy", 0x0214A: "Zyyy", 0x0214B: "Zyyy", 0x0214E: "Latn", 0x0214F: "Zyyy", 0x02189: "Zyyy", 0x021A0: "Zyyy", 0x021A3: "Zyyy", 0x021A6: "Zyyy", 0x021AE: "Zyyy", 0x021D2: "Zyyy", 0x021D3: "Zyyy", 0x021D4: "Zyyy", 0x02308: "Zyyy", 0x02309: "Zyyy", 0x0230A: "Zyyy", 0x0230B: "Zyyy", 0x02329: "Zyyy", 0x0232A: "Zyyy", 0x0237C: "Zyyy", 0x025B7: "Zyyy", 0x025C1: "Zyyy", 0x0266F: "Zyyy", 0x02768: "Zyyy", 0x02769: "Zyyy", 0x0276A: "Zyyy", 0x0276B: "Zyyy", 0x0276C: "Zyyy", 0x0276D: "Zyyy", 0x0276E: "Zyyy", 0x0276F: "Zyyy", 0x02770: "Zyyy", 0x02771: "Zyyy", 0x02772: "Zyyy", 0x02773: "Zyyy", 0x02774: "Zyyy", 0x02775: "Zyyy", 0x027C5: "Zyyy", 0x027C6: "Zyyy", 0x027E6: "Zyyy", 0x027E7: "Zyyy", 0x027E8: "Zyyy", 0x027E9: "Zyyy", 0x027EA: "Zyyy", 0x027EB: "Zyyy", 0x027EC: "Zyyy", 0x027ED: "Zyyy", 0x027EE: "Zyyy", 0x027EF: "Zyyy", 0x02983: "Zyyy", 0x02984: "Zyyy", 0x02985: "Zyyy", 0x02986: "Zyyy", 0x02987: "Zyyy", 0x02988: "Zyyy", 0x02989: "Zyyy", 0x0298A: "Zyyy", 0x0298B: "Zyyy", 0x0298C: "Zyyy", 0x0298D: "Zyyy", 0x0298E: "Zyyy", 0x0298F: "Zyyy", 0x02990: "Zyyy", 0x02991: "Zyyy", 0x02992: "Zyyy", 0x02993: "Zyyy", 0x02994: "Zyyy", 0x02995: "Zyyy", 0x02996: "Zyyy", 0x02997: "Zyyy", 0x02998: "Zyyy", 0x029D8: "Zyyy", 0x029D9: "Zyyy", 0x029DA: "Zyyy", 0x029DB: "Zyyy", 0x029FC: "Zyyy", 0x029FD: "Zyyy", 0x02CFD: "Copt", 0x02D27: "Geor", 0x02D2D: "Geor", 0x02D6F: "Tfng", 0x02D70: "Tfng", 0x02D7F: "Tfng", 0x02E02: "Zyyy", 0x02E03: "Zyyy", 0x02E04: "Zyyy", 0x02E05: "Zyyy", 0x02E09: "Zyyy", 0x02E0A: "Zyyy", 0x02E0B: "Zyyy", 0x02E0C: "Zyyy", 0x02E0D: "Zyyy", 0x02E17: "Zyyy", 0x02E1A: "Zyyy", 0x02E1B: "Zyyy", 0x02E1C: "Zyyy", 0x02E1D: "Zyyy", 0x02E20: "Zyyy", 0x02E21: "Zyyy", 0x02E22: "Zyyy", 0x02E23: "Zyyy", 0x02E24: "Zyyy", 0x02E25: "Zyyy", 0x02E26: "Zyyy", 0x02E27: "Zyyy", 0x02E28: "Zyyy", 0x02E29: "Zyyy", 0x02E2F: "Zyyy", 0x02E40: "Zyyy", 0x02E41: "Zyyy", 0x02E42: "Zyyy", 0x03000: "Zyyy", 0x03004: "Zyyy", 0x03005: "Hani", 0x03006: "Zyyy", 0x03007: "Hani", 0x03008: "Zyyy", 0x03009: "Zyyy", 0x0300A: "Zyyy", 0x0300B: "Zyyy", 0x0300C: "Zyyy", 0x0300D: "Zyyy", 0x0300E: "Zyyy", 0x0300F: "Zyyy", 0x03010: "Zyyy", 0x03011: "Zyyy", 0x03014: "Zyyy", 0x03015: "Zyyy", 0x03016: "Zyyy", 0x03017: "Zyyy", 0x03018: "Zyyy", 0x03019: "Zyyy", 0x0301A: "Zyyy", 0x0301B: "Zyyy", 0x0301C: "Zyyy", 0x0301D: "Zyyy", 0x03020: "Zyyy", 0x03030: "Zyyy", 0x0303B: "Hani", 0x0303C: "Zyyy", 0x0303D: "Zyyy", 0x0309F: "Hira", 0x030A0: "Zyyy", 0x030FB: "Zyyy", 0x030FC: "Zyyy", 0x030FF: "Kana", 0x03250: "Zyyy", 0x0327F: "Zyyy", 0x0A015: "Yiii", 0x0A60C: "Vaii", 0x0A66E: "Cyrl", 0x0A66F: "Cyrl", 0x0A673: "Cyrl", 0x0A67E: "Cyrl", 0x0A67F: "Cyrl", 0x0A770: "Latn", 0x0A788: "Zyyy", 0x0A78F: "Latn", 0x0A7F7: "Latn", 0x0A7FA: "Latn", 0x0A802: "Sylo", 0x0A806: "Sylo", 0x0A80B: "Sylo", 0x0A827: "Sylo", 0x0A838: "Zyyy", 0x0A839: "Zyyy", 0x0A8FB: "Deva", 0x0A8FC: "Deva", 0x0A8FD: "Deva", 0x0A92E: "Zyyy", 0x0A92F: "Kali", 0x0A95F: "Rjng", 0x0A983: "Java", 0x0A9B3: "Java", 0x0A9BC: "Java", 0x0A9CF: "Zyyy", 0x0A9E5: "Mymr", 0x0A9E6: "Mymr", 0x0AA43: "Cham", 0x0AA4C: "Cham", 0x0AA4D: "Cham", 0x0AA70: "Mymr", 0x0AA7A: "Mymr", 0x0AA7B: "Mymr", 0x0AA7C: "Mymr", 0x0AA7D: "Mymr", 0x0AAB0: "Tavt", 0x0AAB1: "Tavt", 0x0AAC0: "Tavt", 0x0AAC1: "Tavt", 0x0AAC2: "Tavt", 0x0AADD: "Tavt", 0x0AAEB: "Mtei", 0x0AAF2: "Mtei", 0x0AAF5: "Mtei", 0x0AAF6: "Mtei", 0x0AB5B: "Zyyy", 0x0AB65: "Grek", 0x0ABE5: "Mtei", 0x0ABE8: "Mtei", 0x0ABEB: "Mtei", 0x0ABEC: "Mtei", 0x0ABED: "Mtei", 0x0FB1D: "Hebr", 0x0FB1E: "Hebr", 0x0FB29: "Hebr", 0x0FB3E: "Hebr", 0x0FD3E: "Zyyy", 0x0FD3F: "Zyyy", 0x0FDFC: "Arab", 0x0FDFD: "Arab", 0x0FE17: "Zyyy", 0x0FE18: "Zyyy", 0x0FE19: "Zyyy", 0x0FE30: "Zyyy", 0x0FE35: "Zyyy", 0x0FE36: "Zyyy", 0x0FE37: "Zyyy", 0x0FE38: "Zyyy", 0x0FE39: "Zyyy", 0x0FE3A: "Zyyy", 0x0FE3B: "Zyyy", 0x0FE3C: "Zyyy", 0x0FE3D: "Zyyy", 0x0FE3E: "Zyyy", 0x0FE3F: "Zyyy", 0x0FE40: "Zyyy", 0x0FE41: "Zyyy", 0x0FE42: "Zyyy", 0x0FE43: "Zyyy", 0x0FE44: "Zyyy", 0x0FE47: "Zyyy", 0x0FE48: "Zyyy", 0x0FE58: "Zyyy", 0x0FE59: "Zyyy", 0x0FE5A: "Zyyy", 0x0FE5B: "Zyyy", 0x0FE5C: "Zyyy", 0x0FE5D: "Zyyy", 0x0FE5E: "Zyyy", 0x0FE62: "Zyyy", 0x0FE63: "Zyyy", 0x0FE68: "Zyyy", 0x0FE69: "Zyyy", 0x0FEFF: "Zyyy", 0x0FF04: "Zyyy", 0x0FF08: "Zyyy", 0x0FF09: "Zyyy", 0x0FF0A: "Zyyy", 0x0FF0B: "Zyyy", 0x0FF0C: "Zyyy", 0x0FF0D: "Zyyy", 0x0FF3B: "Zyyy", 0x0FF3C: "Zyyy", 0x0FF3D: "Zyyy", 0x0FF3E: "Zyyy", 0x0FF3F: "Zyyy", 0x0FF40: "Zyyy", 0x0FF5B: "Zyyy", 0x0FF5C: "Zyyy", 0x0FF5D: "Zyyy", 0x0FF5E: "Zyyy", 0x0FF5F: "Zyyy", 0x0FF60: "Zyyy", 0x0FF61: "Zyyy", 0x0FF62: "Zyyy", 0x0FF63: "Zyyy", 0x0FF70: "Zyyy", 0x0FFE2: "Zyyy", 0x0FFE3: "Zyyy", 0x0FFE4: "Zyyy", 0x0FFE8: "Zyyy", 0x101A0: "Grek", 0x101FD: "Zinh", 0x102E0: "Zinh", 0x10341: "Goth", 0x1034A: "Goth", 0x1039F: "Ugar", 0x103D0: "Xpeo", 0x1056F: "Aghb", 0x10808: "Cprt", 0x1083C: "Cprt", 0x1083F: "Cprt", 0x10857: "Armi", 0x1091F: "Phnx", 0x1093F: "Lydi", 0x10A00: "Khar", 0x10A3F: "Khar", 0x10A7F: "Xpeo", 0x10AC8: "Mani", 0x11000: "Brah", 0x11001: "Brah", 0x11002: "Brah", 0x1107F: "Brah", 0x11082: "Kthi", 0x110BD: "Kthi", 0x1112C: "Cakm", 0x11173: "Mahj", 0x11176: "Mahj", 0x11182: "Shrd", 0x111CD: "Shrd", 0x111DA: "Shrd", 0x111DB: "Shrd", 0x111DC: "Shrd", 0x11234: "Khoj", 0x11235: "Khoj", 0x1123E: "Khoj", 0x11288: "Mult", 0x112A9: "Mult", 0x112DF: "Sind", 0x1133C: "Gran", 0x1133D: "Gran", 0x11340: "Gran", 0x11350: "Gran", 0x11357: "Gran", 0x11445: "Newa", 0x11446: "Newa", 0x1145B: "Newa", 0x1145D: "Newa", 0x114B9: "Tirh", 0x114BA: "Tirh", 0x114C1: "Tirh", 0x114C6: "Tirh", 0x114C7: "Tirh", 0x115BE: "Sidd", 0x1163D: "Modi", 0x1163E: "Modi", 0x11644: "Modi", 0x116AB: "Takr", 0x116AC: "Takr", 0x116AD: "Takr", 0x116B6: "Takr", 0x116B7: "Takr", 0x11726: "Ahom", 0x1173F: "Ahom", 0x118FF: "Wara", 0x11A00: "Zanb", 0x11A39: "Zanb", 0x11A3A: "Zanb", 0x11A47: "Zanb", 0x11A50: "Soyo", 0x11A97: "Soyo", 0x11C2F: "Bhks", 0x11C3E: "Bhks", 0x11C3F: "Bhks", 0x11C40: "Bhks", 0x11CA9: "Marc", 0x11CB1: "Marc", 0x11CB4: "Marc", 0x11D3A: "Gonm", 0x11D46: "Gonm", 0x11D47: "Gonm", 0x16AF5: "Bass", 0x16B44: "Hmng", 0x16B45: "Hmng", 0x16F50: "Plrd", 0x16FE0: "Tang", 0x16FE1: "Nshu", 0x1B000: "Kana", 0x1BC9C: "Dupl", 0x1BC9F: "Dupl", 0x1D245: "Grek", 0x1D4A2: "Zyyy", 0x1D4BB: "Zyyy", 0x1D546: "Zyyy", 0x1D6C1: "Zyyy", 0x1D6DB: "Zyyy", 0x1D6FB: "Zyyy", 0x1D715: "Zyyy", 0x1D735: "Zyyy", 0x1D74F: "Zyyy", 0x1D76F: "Zyyy", 0x1D789: "Zyyy", 0x1D7A9: "Zyyy", 0x1D7C3: "Zyyy", 0x1DA75: "Sgnw", 0x1DA84: "Sgnw", 0x1EE24: "Arab", 0x1EE27: "Arab", 0x1EE39: "Arab", 0x1EE3B: "Arab", 0x1EE42: "Arab", 0x1EE47: "Arab", 0x1EE49: "Arab", 0x1EE4B: "Arab", 0x1EE54: "Arab", 0x1EE57: "Arab", 0x1EE59: "Arab", 0x1EE5B: "Arab", 0x1EE5D: "Arab", 0x1EE5F: "Arab", 0x1EE64: "Arab", 0x1EE7E: "Arab", 0x1F200: "Hira", 0x1F9C0: "Zyyy", 0xE0001: "Zyyy", };

const codepointRanges = [ [ 0x00000, 0x00040, "Zyyy" ], [ 0x00041, 0x0007A, "Latn" ], [ 0x0007F, 0x000BE, "Zyyy" ], [ 0x000C0, 0x002B8, "Latn" ], [ 0x002B9, 0x002DF, "Zyyy" ], [ 0x002E0, 0x002E4, "Latn" ], [ 0x002E5, 0x002E9, "Zyyy" ], [ 0x002EA, 0x002EB, "Bopo" ], [ 0x002EF, 0x002FF, "Zyyy" ], [ 0x00300, 0x0036F, "Zinh" ], [ 0x00370, 0x003E1, "Grek" ], [ 0x003E2, 0x003EF, "Copt" ], [ 0x003F0, 0x003FF, "Grek" ], [ 0x00400, 0x00484, "Cyrl" ], [ 0x00485, 0x00486, "Zinh" ], [ 0x00488, 0x0052F, "Cyrl" ], [ 0x00531, 0x0058E, "Armn" ], [ 0x00591, 0x005F4, "Hebr" ], [ 0x00600, 0x0064A, "Arab" ], [ 0x0064B, 0x00655, "Zinh" ], [ 0x00656, 0x006FE, "Arab" ], [ 0x00700, 0x0074F, "Syrc" ], [ 0x00750, 0x0077F, "Arab" ], [ 0x00780, 0x007B0, "Thaa" ], [ 0x007C0, 0x007F9, "Nkoo" ], [ 0x00800, 0x0083E, "Samr" ], [ 0x00840, 0x0085B, "Mand" ], [ 0x00860, 0x0086A, "Syrc" ], [ 0x008A0, 0x008FF, "Arab" ], [ 0x00900, 0x0094F, "Deva" ], [ 0x00951, 0x00952, "Zinh" ], [ 0x00953, 0x00963, "Deva" ], [ 0x00964, 0x00965, "Zyyy" ], [ 0x00966, 0x0097F, "Deva" ], [ 0x00982, 0x009F9, "Beng" ], [ 0x00A01, 0x00A74, "Guru" ], [ 0x00A81, 0x00AFF, "Gujr" ], [ 0x00B02, 0x00B77, "Orya" ], [ 0x00B85, 0x00BF8, "Taml" ], [ 0x00C01, 0x00C7E, "Telu" ], [ 0x00C82, 0x00CF2, "Knda" ], [ 0x00D00, 0x00D7F, "Mlym" ], [ 0x00D82, 0x00DF3, "Sinh" ], [ 0x00E01, 0x00E5B, "Thai" ], [ 0x00E81, 0x00EDF, "Laoo" ], [ 0x00F01, 0x00FD4, "Tibt" ], [ 0x00FD5, 0x00FD8, "Zyyy" ], [ 0x00FD9, 0x00FDA, "Tibt" ], [ 0x01000, 0x0109F, "Mymr" ], [ 0x010A0, 0x010FF, "Geor" ], [ 0x01100, 0x011FF, "Hang" ], [ 0x01200, 0x01399, "Ethi" ], [ 0x013A0, 0x013FD, "Cher" ], [ 0x01401, 0x0167F, "Cans" ], [ 0x01681, 0x0169A, "Ogam" ], [ 0x016A0, 0x016EA, "Runr" ], [ 0x016EB, 0x016ED, "Zyyy" ], [ 0x016EE, 0x016F8, "Runr" ], [ 0x01700, 0x01714, "Tglg" ], [ 0x01720, 0x01734, "Hano" ], [ 0x01735, 0x01736, "Zyyy" ], [ 0x01740, 0x01753, "Buhd" ], [ 0x01760, 0x01773, "Tagb" ], [ 0x01780, 0x017F9, "Khmr" ], [ 0x01800, 0x01801, "Mong" ], [ 0x01802, 0x01803, "Zyyy" ], [ 0x01807, 0x018A8, "Mong" ], [ 0x018B0, 0x018F5, "Cans" ], [ 0x01900, 0x0194F, "Limb" ], [ 0x01950, 0x01974, "Tavt" ], [ 0x01980, 0x019DF, "Talu" ], [ 0x019E0, 0x019FF, "Khmr" ], [ 0x01A00, 0x01A1F, "Bugi" ], [ 0x01A20, 0x01AAD, "Tavt" ], [ 0x01AB0, 0x01ABD, "Zinh" ], [ 0x01B00, 0x01B7C, "Bali" ], [ 0x01B80, 0x01BBF, "Sund" ], [ 0x01BC0, 0x01BFF, "Batk" ], [ 0x01C00, 0x01C4F, "Lepc" ], [ 0x01C50, 0x01C7F, "Olck" ], [ 0x01C80, 0x01C88, "Cyrl" ], [ 0x01CC0, 0x01CC7, "Sund" ], [ 0x01CD0, 0x01CE8, "Zinh" ], [ 0x01CE9, 0x01CF6, "Zyyy" ], [ 0x01CF8, 0x01CF9, "Zinh" ], [ 0x01D00, 0x01D25, "Latn" ], [ 0x01D26, 0x01D2A, "Grek" ], [ 0x01D2C, 0x01D5C, "Latn" ], [ 0x01D5D, 0x01D61, "Grek" ], [ 0x01D62, 0x01D65, "Latn" ], [ 0x01D66, 0x01D6A, "Grek" ], [ 0x01D6B, 0x01DBE, "Latn" ], [ 0x01DC0, 0x01DFF, "Zinh" ], [ 0x01E00, 0x01EFF, "Latn" ], [ 0x01F00, 0x01FFE, "Grek" ], [ 0x02000, 0x0200A, "Zyyy" ], [ 0x0200C, 0x0200D, "Zinh" ], [ 0x0200E, 0x0208C, "Zyyy" ], [ 0x02090, 0x0209C, "Latn" ], [ 0x020A0, 0x020BF, "Zyyy" ], [ 0x020D0, 0x020F0, "Zinh" ], [ 0x02100, 0x02123, "Zyyy" ], [ 0x0212A, 0x0212B, "Latn" ], [ 0x0212C, 0x0215F, "Zyyy" ], [ 0x02160, 0x02188, "Latn" ], [ 0x0218A, 0x027FF, "Zyyy" ], [ 0x02800, 0x028FF, "Brai" ], [ 0x02900, 0x02BEF, "Zyyy" ], [ 0x02C00, 0x02C5E, "Glag" ], [ 0x02C60, 0x02C7F, "Latn" ], [ 0x02C80, 0x02CFF, "Copt" ], [ 0x02D00, 0x02D25, "Geor" ], [ 0x02D30, 0x02D67, "Tfng" ], [ 0x02D80, 0x02DDE, "Ethi" ], [ 0x02DE0, 0x02DFF, "Cyrl" ], [ 0x02E00, 0x02E49, "Zyyy" ], [ 0x02E80, 0x02FD5, "Hani" ], [ 0x02FF0, 0x0301F, "Zyyy" ], [ 0x03021, 0x03029, "Hani" ], [ 0x0302A, 0x0302D, "Zinh" ], [ 0x0302E, 0x0302F, "Hang" ], [ 0x03031, 0x03037, "Zyyy" ], [ 0x03038, 0x0303A, "Hani" ], [ 0x0303E, 0x0303F, "Zyyy" ], [ 0x03041, 0x03096, "Hira" ], [ 0x03099, 0x0309A, "Zinh" ], [ 0x0309B, 0x0309C, "Zyyy" ], [ 0x0309D, 0x0309E, "Hira" ], [ 0x030A1, 0x030FE, "Kana" ], [ 0x03105, 0x0312E, "Bopo" ], [ 0x03131, 0x0318E, "Hang" ], [ 0x03190, 0x0319F, "Zyyy" ], [ 0x031A0, 0x031BA, "Bopo" ], [ 0x031C0, 0x031E3, "Zyyy" ], [ 0x031F0, 0x031FF, "Kana" ], [ 0x03200, 0x0321E, "Hang" ], [ 0x03220, 0x0325F, "Zyyy" ], [ 0x03260, 0x0327E, "Hang" ], [ 0x03280, 0x032CF, "Zyyy" ], [ 0x032D0, 0x03357, "Kana" ], [ 0x03358, 0x033FF, "Zyyy" ], [ 0x03400, 0x04DB5, "Hani" ], [ 0x04DC0, 0x04DFF, "Zyyy" ], [ 0x04E00, 0x09FEA, "Hani" ], [ 0x0A000, 0x0A4C6, "Yiii" ], [ 0x0A4D0, 0x0A4FF, "Lisu" ], [ 0x0A500, 0x0A62B, "Vaii" ], [ 0x0A640, 0x0A69F, "Cyrl" ], [ 0x0A6A0, 0x0A6F7, "Bamu" ], [ 0x0A700, 0x0A721, "Zyyy" ], [ 0x0A722, 0x0A787, "Latn" ], [ 0x0A789, 0x0A78A, "Zyyy" ], [ 0x0A78B, 0x0A7FF, "Latn" ], [ 0x0A800, 0x0A82B, "Sylo" ], [ 0x0A830, 0x0A837, "Zyyy" ], [ 0x0A840, 0x0A877, "Phag" ], [ 0x0A880, 0x0A8D9, "Saur" ], [ 0x0A8E0, 0x0A8FA, "Deva" ], [ 0x0A900, 0x0A92D, "Kali" ], [ 0x0A930, 0x0A953, "Rjng" ], [ 0x0A960, 0x0A97C, "Hang" ], [ 0x0A980, 0x0A9DF, "Java" ], [ 0x0A9E0, 0x0A9FE, "Mymr" ], [ 0x0AA00, 0x0AA5F, "Cham" ], [ 0x0AA60, 0x0AA7F, "Mymr" ], [ 0x0AA80, 0x0AADF, "Tavt" ], [ 0x0AAE0, 0x0AAF4, "Mtei" ], [ 0x0AB01, 0x0AB2E, "Ethi" ], [ 0x0AB30, 0x0AB64, "Latn" ], [ 0x0AB70, 0x0ABBF, "Cher" ], [ 0x0ABC0, 0x0ABF9, "Mtei" ], [ 0x0AC00, 0x0D7FB, "Hang" ], [ 0x0F900, 0x0FAD9, "Hani" ], [ 0x0FB00, 0x0FB06, "Latn" ], [ 0x0FB13, 0x0FB17, "Armn" ], [ 0x0FB1F, 0x0FB4F, "Hebr" ], [ 0x0FB50, 0x0FDFB, "Arab" ], [ 0x0FE00, 0x0FE0F, "Zinh" ], [ 0x0FE10, 0x0FE16, "Zyyy" ], [ 0x0FE20, 0x0FE2D, "Zinh" ], [ 0x0FE2E, 0x0FE2F, "Cyrl" ], [ 0x0FE31, 0x0FE6B, "Zyyy" ], [ 0x0FE70, 0x0FEFC, "Arab" ], [ 0x0FF01, 0x0FF20, "Zyyy" ], [ 0x0FF21, 0x0FF5A, "Latn" ], [ 0x0FF64, 0x0FF65, "Zyyy" ], [ 0x0FF66, 0x0FF9D, "Kana" ], [ 0x0FF9E, 0x0FF9F, "Zyyy" ], [ 0x0FFA0, 0x0FFDC, "Hang" ], [ 0x0FFE0, 0x0FFFD, "Zyyy" ], [ 0x10000, 0x100FA, "Linb" ], [ 0x10100, 0x1013F, "Zyyy" ], [ 0x10140, 0x1018E, "Grek" ], [ 0x10190, 0x101FC, "Zyyy" ], [ 0x10280, 0x1029C, "Lyci" ], [ 0x102A0, 0x102D0, "Cari" ], [ 0x102E1, 0x102FB, "Zyyy" ], [ 0x10300, 0x1032F, "Xpeo" ], [ 0x10330, 0x10349, "Goth" ], [ 0x10350, 0x1037A, "Xpeo" ], [ 0x10380, 0x1039D, "Ugar" ], [ 0x103A0, 0x103D5, "Xpeo" ], [ 0x10400, 0x1044F, "Dsrt" ], [ 0x10450, 0x1047F, "Shaw" ], [ 0x10480, 0x104A9, "Osma" ], [ 0x104B0, 0x104FB, "Osge" ], [ 0x10500, 0x10527, "Elba" ], [ 0x10530, 0x10563, "Aghb" ], [ 0x10600, 0x10767, "Linb" ], [ 0x10800, 0x10838, "Cprt" ], [ 0x10840, 0x1085F, "Armi" ], [ 0x10860, 0x1087F, "Palm" ], [ 0x10880, 0x108AF, "Nbat" ], [ 0x108E0, 0x108FF, "Hatr" ], [ 0x10900, 0x1091B, "Phnx" ], [ 0x10920, 0x10939, "Lydi" ], [ 0x10980, 0x109FF, "Mero" ], [ 0x10A01, 0x10A58, "Khar" ], [ 0x10A60, 0x10A9F, "Xpeo" ], [ 0x10AC0, 0x10AF6, "Mani" ], [ 0x10B00, 0x10B3F, "Avst" ], [ 0x10B40, 0x10B7F, "Prti" ], [ 0x10B80, 0x10BAF, "Phlp" ], [ 0x10C00, 0x10CFF, "Xpeo" ], [ 0x10E60, 0x10E7E, "Arab" ], [ 0x11003, 0x1106F, "Brah" ], [ 0x11080, 0x110C1, "Kthi" ], [ 0x110D0, 0x110F9, "Sora" ], [ 0x11100, 0x11143, "Cakm" ], [ 0x11150, 0x11175, "Mahj" ], [ 0x11180, 0x111DF, "Shrd" ], [ 0x111E1, 0x111F4, "Sinh" ], [ 0x11200, 0x1123D, "Khoj" ], [ 0x11280, 0x112A8, "Mult" ], [ 0x112B0, 0x112F9, "Sind" ], [ 0x11300, 0x11374, "Gran" ], [ 0x11400, 0x11459, "Newa" ], [ 0x11480, 0x114D9, "Tirh" ], [ 0x11580, 0x115DD, "Sidd" ], [ 0x11600, 0x11659, "Modi" ], [ 0x11660, 0x1166C, "Mong" ], [ 0x11680, 0x116C9, "Takr" ], [ 0x11700, 0x1173E, "Ahom" ], [ 0x118A0, 0x118F2, "Wara" ], [ 0x11A01, 0x11A46, "Zanb" ], [ 0x11A51, 0x11AA2, "Soyo" ], [ 0x11AC0, 0x11AF8, "Pauc" ], [ 0x11C00, 0x11C6C, "Bhks" ], [ 0x11C70, 0x11CB6, "Marc" ], [ 0x11D00, 0x11D59, "Gonm" ], [ 0x12000, 0x12543, "Xsux" ], [ 0x13000, 0x1342E, "Egyp" ], [ 0x14400, 0x14646, "Hluw" ], [ 0x16800, 0x16A38, "Bamu" ], [ 0x16A40, 0x16A6F, "Mroo" ], [ 0x16AD0, 0x16AF4, "Bass" ], [ 0x16B00, 0x16B8F, "Hmng" ], [ 0x16F00, 0x16F9F, "Plrd" ], [ 0x17000, 0x18AF2, "Tang" ], [ 0x1B001, 0x1B11E, "Hira" ], [ 0x1B170, 0x1B2FB, "Nshu" ], [ 0x1BC00, 0x1BC9E, "Dupl" ], [ 0x1BCA0, 0x1D166, "Zyyy" ], [ 0x1D167, 0x1D169, "Zinh" ], [ 0x1D16A, 0x1D17A, "Zyyy" ], [ 0x1D17B, 0x1D182, "Zinh" ], [ 0x1D183, 0x1D184, "Zyyy" ], [ 0x1D185, 0x1D18B, "Zinh" ], [ 0x1D18C, 0x1D1A9, "Zyyy" ], [ 0x1D1AA, 0x1D1AD, "Zinh" ], [ 0x1D1AE, 0x1D1E8, "Zyyy" ], [ 0x1D200, 0x1D244, "Grek" ], [ 0x1D300, 0x1D7FF, "Zyyy" ], [ 0x1D800, 0x1DAAF, "Sgnw" ], [ 0x1E000, 0x1E02A, "Glag" ], [ 0x1E800, 0x1E8D6, "Mend" ], [ 0x1E900, 0x1E95F, "Adlm" ], [ 0x1EE00, 0x1EEF1, "Arab" ], [ 0x1F000, 0x1F9E6, "Zyyy" ], [ 0x20000, 0x2FA1D, "Hani" ], [ 0xE0020, 0xE007F, "Zyyy" ], [ 0xE0100, 0xE01EF, "Zinh" ], ];

function simpleSearch(codePoint, ranges) { for (let [lower, higher, result] of ranges) { // If ranges are greater than codepoint, no match will be found. Short-circuit the loop. if ( codePoint < lower) { return null; } else if (codePoint <= higher) { return result; }	} }

function sortRanges(range1, range2) { if (range1[0] === range2[0]) { return range1[1] - range2[1]; } else { return range1[0] - range2[0]; } }

function binarySearch(codePoint, ranges) { if (!ranges) { return null; }

if (binarySearch.cache) { let cacheResult = simpleSearch(codePoint, binarySearch.cache);

if (cacheResult) { return cacheResult; }	} else { binarySearch.cache = []; }

let iBottom = 0, iMiddle = 0, iTop = ranges.length;

while (iBottom <= iTop) { iMiddle = (iBottom + iTop) >> 1; let range = ranges[iMiddle]; if (range === undefined) { return null; }		if (codePoint < range[0]) { iTop = iMiddle - 1; } else if (codePoint <= range[1]) { binarySearch.cache.push(range); binarySearch.cache.sort(sortRanges); return range[2]; } else { iBottom = iMiddle + 1; }	}

return null; }

// Returns a string (a Unicode script code) or null. function codePointToScript(codePoint) { return individual[codePoint] || binarySearch(codePoint, codepointRanges); }

// Takes a string, returns an object with script codes mapped to the number of // characters of that script that were found. function countScripts(text) { const scriptCounts = {}; for (const character of text) { const script = codePointToScript(character.codePointAt(0)); scriptCounts[script] = (scriptCounts[script] || 0) + 1; }	return scriptCounts; }

function countSignificantScripts(text) { const scriptCounts = {}; for (const character of text) { const script = codePointToScript(character.codePointAt(0)); if (!ignoredScripts.includes(script)) { scriptCounts[script] = (scriptCounts[script] || 0) + 1; }	}	return scriptCounts; }

window.codePointToScript = codePointToScript; window.countScripts = countScripts; window.countSignificantScripts = countSignificantScripts;

//