diff --git a/Unic.yyp b/Unic.yyp index 55788298..86dd6496 100644 --- a/Unic.yyp +++ b/Unic.yyp @@ -16,9 +16,9 @@ {"$GMFolder":"","%Name":"Unic CLDR Database Generator","folderPath":"folders/(Unic Generators)/Unic CLDR Database Generator.yy","name":"Unic CLDR Database Generator","resourceType":"GMFolder","resourceVersion":"2.0",}, {"$GMFolder":"","%Name":"Unic Linebreak Database Generator","folderPath":"folders/(Unic Generators)/Unic Linebreak Database Generator.yy","name":"Unic Linebreak Database Generator","resourceType":"GMFolder","resourceVersion":"2.0",}, {"$GMFolder":"","%Name":"Unic UnicodeData.txt Database Generator","folderPath":"folders/(Unic Generators)/Unic UnicodeData.txt Database Generator.yy","name":"Unic UnicodeData.txt Database Generator","resourceType":"GMFolder","resourceVersion":"2.0",}, - {"$GMFolder":"","%Name":"Unic Blocks","folderPath":"folders/Unic Blocks.yy","name":"Unic Blocks","resourceType":"GMFolder","resourceVersion":"2.0",}, {"$GMFolder":"","%Name":"Unic","folderPath":"folders/Unic.yy","name":"Unic","resourceType":"GMFolder","resourceVersion":"2.0",}, {"$GMFolder":"","%Name":"(System)","folderPath":"folders/Unic/(System).yy","name":"(System)","resourceType":"GMFolder","resourceVersion":"2.0",}, + {"$GMFolder":"","%Name":"Blocks","folderPath":"folders/Unic/Blocks.yy","name":"Blocks","resourceType":"GMFolder","resourceVersion":"2.0",}, {"$GMFolder":"","%Name":"Constants","folderPath":"folders/Unic/Constants.yy","name":"Constants","resourceType":"GMFolder","resourceVersion":"2.0",}, {"$GMFolder":"","%Name":"Formatters","folderPath":"folders/Unic/Formatters.yy","name":"Formatters","resourceType":"GMFolder","resourceVersion":"2.0",}, {"$GMFolder":"","%Name":"Getters","folderPath":"folders/Unic/Getters.yy","name":"Getters","resourceType":"GMFolder","resourceVersion":"2.0",}, @@ -71,6 +71,8 @@ {"id":{"name":"__UnicUnicodeDataGenerateDatabase","path":"scripts/__UnicUnicodeDataGenerateDatabase/__UnicUnicodeDataGenerateDatabase.yy",},}, {"id":{"name":"SnapBufferReadCSV","path":"scripts/SnapBufferReadCSV/SnapBufferReadCSV.yy",},}, {"id":{"name":"SnapBufferWriteCSV","path":"scripts/SnapBufferWriteCSV/SnapBufferWriteCSV.yy",},}, + {"id":{"name":"UnicBlockGetRanges","path":"scripts/UnicBlockGetRanges/UnicBlockGetRanges.yy",},}, + {"id":{"name":"UnicBlockGetRangesExt","path":"scripts/UnicBlockGetRangesExt/UnicBlockGetRangesExt.yy",},}, {"id":{"name":"UnicClock","path":"scripts/UnicClock/UnicClock.yy",},}, {"id":{"name":"UnicClockExt","path":"scripts/UnicClockExt/UnicClockExt.yy",},}, {"id":{"name":"UnicCurrency","path":"scripts/UnicCurrency/UnicCurrency.yy",},}, diff --git a/objects/obj_unic_test/Create_0.gml b/objects/obj_unic_test/Create_0.gml index 7f8ee451..5dad7b5b 100644 --- a/objects/obj_unic_test/Create_0.gml +++ b/objects/obj_unic_test/Create_0.gml @@ -95,6 +95,7 @@ repeat(3) } show_debug_message(UnicGetCharacters("ja")); +show_debug_message(json_stringify(UnicBlockGetRanges(UnicGetCharacters("ja")), true)); if (os_get_config() == "Unit_Test") { game_end(); diff --git a/scripts/UnicBlockGetRanges/UnicBlockGetRanges.gml b/scripts/UnicBlockGetRanges/UnicBlockGetRanges.gml new file mode 100644 index 00000000..2e375344 --- /dev/null +++ b/scripts/UnicBlockGetRanges/UnicBlockGetRanges.gml @@ -0,0 +1,12 @@ +// Feather disable all + +/// Returns an array of structs with all of the valid character block ranges, based on the provided string characters. +/// These character block ranges are derived from https://www.unicode.org/charts/, and Blocks.txt respectively. +/// +/// @param {String} string +/// @return {Array} +function UnicBlockGetRanges(_str) { + var _results = []; + UnicBlockGetRangesExt(_results, _str); + return _results; +} \ No newline at end of file diff --git a/scripts/UnicBlockGetRanges/UnicBlockGetRanges.yy b/scripts/UnicBlockGetRanges/UnicBlockGetRanges.yy new file mode 100644 index 00000000..96267eef --- /dev/null +++ b/scripts/UnicBlockGetRanges/UnicBlockGetRanges.yy @@ -0,0 +1,13 @@ +{ + "$GMScript":"v1", + "%Name":"UnicBlockGetRanges", + "isCompatibility":false, + "isDnD":false, + "name":"UnicBlockGetRanges", + "parent":{ + "name":"Blocks", + "path":"folders/Unic/Blocks.yy", + }, + "resourceType":"GMScript", + "resourceVersion":"2.0", +} \ No newline at end of file diff --git a/scripts/UnicBlockGetRangesExt/UnicBlockGetRangesExt.gml b/scripts/UnicBlockGetRangesExt/UnicBlockGetRangesExt.gml new file mode 100644 index 00000000..c0243b7e --- /dev/null +++ b/scripts/UnicBlockGetRangesExt/UnicBlockGetRangesExt.gml @@ -0,0 +1,80 @@ +// Feather disable all + +/// Returns a count of all the valid character block ranges, based on the provided string characters. +/// The provided array is updated as well to include these character block ranges at the end. +/// These character block ranges are derived from https://www.unicode.org/charts/, and Blocks.txt respectively. +/// +/// @param {Array} array +/// @param {String} string +/// @param {String} ... +/// @return {Real} +function UnicBlockGetRangesExt(_array, _str) { + static _ctx = { + _results: undefined, + _count: 0, + min: infinity, + max: -infinity, + addedEntry: false, + } + + static _callback = function(_char, _pos) { + static _db = __UnicDatabaseBlocks(); + static _len = array_length(_db); + static _cachePos = 0; + var _charCode = ord(_char); + // Very early exit + if (addedEntry) { + if (_charCode >= self.min && _charCode <= self.max) { + return; + } + } + + // Cache handling, speeds up character codes that are apart of a similar group. + var _entry = _db[_cachePos]; + var _min = _entry.min; + var _max = _entry.max; + if (_charCode >= _min && _charCode <= _max) { + // Entry found, add if dupe doesn't exist and exit! + if (array_get_index(_results, _entry) == -1) { + array_push(_results, _entry); + addedEntry = true; + ++_count; + } + self.min = _min; + self.max = _max; + return; + } + + for(var _i = 0; _i < _len; ++_i) { + _entry = _db[_i]; + _min = _entry.min; + _max = _entry.max; + if (_charCode >= _min && _charCode <= _max) { + // Entry found, add if dupe doesn't exist and exit! + if (array_get_index(_results, _entry) == -1) { + array_push(_results, _entry); + addedEntry = true; + ++_count; + } + _cachePos = _i; + self.min = _min; + self.max = _max; + return; + } + } + }; + + + _ctx._results = _array; + _ctx._count = 0; + _ctx.min = infinity; + _ctx.max = -infinity; + _ctx.addedEntry = false; + with(_ctx) { + for(var _i = 1; _i < argument_count; ++_i) { + string_foreach(argument[_i], _callback); + } + } + _ctx._results = undefined; + return _ctx._count; +} \ No newline at end of file diff --git a/scripts/UnicBlockGetRangesExt/UnicBlockGetRangesExt.yy b/scripts/UnicBlockGetRangesExt/UnicBlockGetRangesExt.yy new file mode 100644 index 00000000..b4e013a3 --- /dev/null +++ b/scripts/UnicBlockGetRangesExt/UnicBlockGetRangesExt.yy @@ -0,0 +1,13 @@ +{ + "$GMScript":"v1", + "%Name":"UnicBlockGetRangesExt", + "isCompatibility":false, + "isDnD":false, + "name":"UnicBlockGetRangesExt", + "parent":{ + "name":"Blocks", + "path":"folders/Unic/Blocks.yy", + }, + "resourceType":"GMScript", + "resourceVersion":"2.0", +} \ No newline at end of file diff --git a/scripts/__UnicBlocksGenerateDatabase/__UnicBlocksGenerateDatabase.gml b/scripts/__UnicBlocksGenerateDatabase/__UnicBlocksGenerateDatabase.gml index d22d1b53..238b53c0 100644 --- a/scripts/__UnicBlocksGenerateDatabase/__UnicBlocksGenerateDatabase.gml +++ b/scripts/__UnicBlocksGenerateDatabase/__UnicBlocksGenerateDatabase.gml @@ -5,7 +5,7 @@ function __UnicBlocksGenerateDatabase() { buffer_delete(_buff); var _writeBuff = buffer_create(1, buffer_grow, 1); - buffer_write(_writeBuff, buffer_text, "// feather ignore all\n/// @ignore\n"); + buffer_write(_writeBuff, buffer_text, "// Feather ignore all\n/// @ignore\n"); buffer_write(_writeBuff, buffer_text, "function __UnicDatabaseBlocks() {\n static _inst = [\n"); var _results = string_split(_str, "\n"); for(var _i = 0; _i < array_length(_results); ++_i) { diff --git a/scripts/__UnicDatabaseBlocks/__UnicDatabaseBlocks.gml b/scripts/__UnicDatabaseBlocks/__UnicDatabaseBlocks.gml index e91fa92a..d6af6c62 100644 --- a/scripts/__UnicDatabaseBlocks/__UnicDatabaseBlocks.gml +++ b/scripts/__UnicDatabaseBlocks/__UnicDatabaseBlocks.gml @@ -1,4 +1,4 @@ -// feather ignore all +// Feather ignore all /// @ignore function __UnicDatabaseBlocks() { static _inst = [ @@ -977,6 +977,11 @@ function __UnicDatabaseBlocks() { max: 0x1093F, description: "Lydian", }, + { + min: 0x10940, + max: 0x1095F, + description: "Sidetic", + }, { min: 0x10980, max: 0x1099F, @@ -1232,6 +1237,11 @@ function __UnicDatabaseBlocks() { max: 0x11B5F, description: "Devanagari Extended-A", }, + { + min: 0x11B60, + max: 0x11B7F, + description: "Sharada Supplement", + }, { min: 0x11BC0, max: 0x11BFF, @@ -1257,6 +1267,11 @@ function __UnicDatabaseBlocks() { max: 0x11DAF, description: "Gunjala Gondi", }, + { + min: 0x11DB0, + max: 0x11DEF, + description: "Tolong Siki", + }, { min: 0x11EE0, max: 0x11EFF, @@ -1357,6 +1372,11 @@ function __UnicDatabaseBlocks() { max: 0x16E9F, description: "Medefaidrin", }, + { + min: 0x16EA0, + max: 0x16EDF, + description: "Beria Erfe", + }, { min: 0x16F00, max: 0x16F9F, @@ -1387,6 +1407,11 @@ function __UnicDatabaseBlocks() { max: 0x18D7F, description: "Tangut Supplement", }, + { + min: 0x18D80, + max: 0x18DFF, + description: "Tangut Components Supplement", + }, { min: 0x1AFF0, max: 0x1AFFF, @@ -1427,6 +1452,11 @@ function __UnicDatabaseBlocks() { max: 0x1CEBF, description: "Symbols for Legacy Computing Supplement", }, + { + min: 0x1CEC0, + max: 0x1CEFF, + description: "Miscellaneous Symbols Supplement", + }, { min: 0x1CF00, max: 0x1CFCF, @@ -1517,6 +1547,11 @@ function __UnicDatabaseBlocks() { max: 0x1E5FF, description: "Ol Onal", }, + { + min: 0x1E6C0, + max: 0x1E6FF, + description: "Tai Yo", + }, { min: 0x1E7E0, max: 0x1E7FF, @@ -1672,6 +1707,11 @@ function __UnicDatabaseBlocks() { max: 0x323AF, description: "CJK Unified Ideographs Extension H", }, + { + min: 0x323B0, + max: 0x3347F, + description: "CJK Unified Ideographs Extension J", + }, { min: 0xE0000, max: 0xE007F, diff --git a/scripts/__UnicDatabaseBlocks/__UnicDatabaseBlocks.yy b/scripts/__UnicDatabaseBlocks/__UnicDatabaseBlocks.yy index 9a9a4c38..6e430c3d 100644 --- a/scripts/__UnicDatabaseBlocks/__UnicDatabaseBlocks.yy +++ b/scripts/__UnicDatabaseBlocks/__UnicDatabaseBlocks.yy @@ -5,8 +5,8 @@ "isDnD":false, "name":"__UnicDatabaseBlocks", "parent":{ - "name":"Unic Blocks", - "path":"folders/Unic Blocks.yy", + "name":"(System)", + "path":"folders/Unic/(System).yy", }, "resourceType":"GMScript", "resourceVersion":"2.0", diff --git a/scripts/__UnicLineBreak/__UnicLineBreak.gml b/scripts/__UnicLineBreak/__UnicLineBreak.gml index f38619c2..4d54b80e 100644 --- a/scripts/__UnicLineBreak/__UnicLineBreak.gml +++ b/scripts/__UnicLineBreak/__UnicLineBreak.gml @@ -1,3 +1,5 @@ +// https://www.unicode.org/reports/tr14/ + enum UnicLineBreak { MANDATORY_BREAK = 0, // BK CARRIAGE_RETURN = 1, // CR diff --git a/unicode-specifics/Blocks.txt b/unicode-specifics/Blocks.txt index 1517dde0..5c24ab60 100644 --- a/unicode-specifics/Blocks.txt +++ b/unicode-specifics/Blocks.txt @@ -1,6 +1,6 @@ -# Blocks-16.0.0.txt -# Date: 2024-02-02 -# © 2024 Unicode®, Inc. +# Blocks-17.0.0.txt +# Date: 2025-08-01 +# © 2025 Unicode®, Inc. # Unicode and the Unicode Logo are registered trademarks of Unicode, Inc. in the U.S. and other countries. # For terms of use and license, see https://www.unicode.org/terms_of_use.html # @@ -228,6 +228,7 @@ FFF0..FFFF; Specials 108E0..108FF; Hatran 10900..1091F; Phoenician 10920..1093F; Lydian +10940..1095F; Sidetic 10980..1099F; Meroitic Hieroglyphs 109A0..109FF; Meroitic Cursive 10A00..10A5F; Kharoshthi @@ -279,11 +280,13 @@ FFF0..FFFF; Specials 11AB0..11ABF; Unified Canadian Aboriginal Syllabics Extended-A 11AC0..11AFF; Pau Cin Hau 11B00..11B5F; Devanagari Extended-A +11B60..11B7F; Sharada Supplement 11BC0..11BFF; Sunuwar 11C00..11C6F; Bhaiksuki 11C70..11CBF; Marchen 11D00..11D5F; Masaram Gondi 11D60..11DAF; Gunjala Gondi +11DB0..11DEF; Tolong Siki 11EE0..11EFF; Makasar 11F00..11F5F; Kawi 11FB0..11FBF; Lisu Supplement @@ -304,12 +307,14 @@ FFF0..FFFF; Specials 16B00..16B8F; Pahawh Hmong 16D40..16D7F; Kirat Rai 16E40..16E9F; Medefaidrin +16EA0..16EDF; Beria Erfe 16F00..16F9F; Miao 16FE0..16FFF; Ideographic Symbols and Punctuation 17000..187FF; Tangut 18800..18AFF; Tangut Components 18B00..18CFF; Khitan Small Script 18D00..18D7F; Tangut Supplement +18D80..18DFF; Tangut Components Supplement 1AFF0..1AFFF; Kana Extended-B 1B000..1B0FF; Kana Supplement 1B100..1B12F; Kana Extended-A @@ -318,6 +323,7 @@ FFF0..FFFF; Specials 1BC00..1BC9F; Duployan 1BCA0..1BCAF; Shorthand Format Controls 1CC00..1CEBF; Symbols for Legacy Computing Supplement +1CEC0..1CEFF; Miscellaneous Symbols Supplement 1CF00..1CFCF; Znamenny Musical Notation 1D000..1D0FF; Byzantine Musical Symbols 1D100..1D1FF; Musical Symbols @@ -336,6 +342,7 @@ FFF0..FFFF; Specials 1E2C0..1E2FF; Wancho 1E4D0..1E4FF; Nag Mundari 1E5D0..1E5FF; Ol Onal +1E6C0..1E6FF; Tai Yo 1E7E0..1E7FF; Ethiopic Extended-B 1E800..1E8DF; Mende Kikakui 1E900..1E95F; Adlam @@ -367,6 +374,7 @@ FFF0..FFFF; Specials 2F800..2FA1F; CJK Compatibility Ideographs Supplement 30000..3134F; CJK Unified Ideographs Extension G 31350..323AF; CJK Unified Ideographs Extension H +323B0..3347F; CJK Unified Ideographs Extension J E0000..E007F; Tags E0100..E01EF; Variation Selectors Supplement F0000..FFFFF; Supplementary Private Use Area-A