From df05eac6caedcbf1e1a4dbb187e05cd37be1c1e5 Mon Sep 17 00:00:00 2001 From: OphidieDev <83857517+OphidieDev@users.noreply.github.com> Date: Mon, 26 May 2025 03:25:21 -0400 Subject: [PATCH 01/21] chore: add basic pesde file --- pesde.toml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 pesde.toml diff --git a/pesde.toml b/pesde.toml new file mode 100644 index 0000000..9babd51 --- /dev/null +++ b/pesde.toml @@ -0,0 +1,19 @@ +name = "ophidiedev/utf8_validate" +version = "0.1.0" +description = "UTF8 validator" +repository = "https://github.com/OphidieDev/utf8-validate" +license = "MIT" + +[target] +environment = "roblox" + +[indices] +default = "https://github.com/pesde-pkg/index" + +[scripts] +roblox_sync_config_generator = ".pesde/scripts/roblox_sync_config_generator.luau" +sourcemap_generator = ".pesde/scripts/sourcemap_generator.luau" + +[dev_dependencies] +scripts = { name = "pesde/scripts_rojo", version = "^0.1.0", target = "lune" } +rojo = { name = "pesde/rojo", version = "^7.4.4", target = "lune" } From 5b0b4dd97f58e3e9edd9582eff7f5eb1c61042c5 Mon Sep 17 00:00:00 2001 From: OphidieDev <83857517+OphidieDev@users.noreply.github.com> Date: Mon, 26 May 2025 03:33:09 -0400 Subject: [PATCH 02/21] feat: swap to rokit for binary management --- aftman.toml | 7 ------- rokit.toml | 3 +++ 2 files changed, 3 insertions(+), 7 deletions(-) delete mode 100644 aftman.toml create mode 100644 rokit.toml diff --git a/aftman.toml b/aftman.toml deleted file mode 100644 index 159fdf4..0000000 --- a/aftman.toml +++ /dev/null @@ -1,7 +0,0 @@ -# This file lists tools managed by Aftman, a cross-platform toolchain manager. -# For more information, see https://github.com/LPGhatguy/aftman - -# To add a new tool, add an entry to this table. -[tools] -rojo = "rojo-rbx/rojo@7.5.1" -# rojo = "rojo-rbx/rojo@6.2.0" \ No newline at end of file diff --git a/rokit.toml b/rokit.toml new file mode 100644 index 0000000..76eb82d --- /dev/null +++ b/rokit.toml @@ -0,0 +1,3 @@ +[tools] +rojo = "rojo-rbx/rojo@7.5.1" +wally = "UpliftGames/wally@0.3.2" From f48fff559683eb2ffcab374b96c585f3843c5575 Mon Sep 17 00:00:00 2001 From: OphidieDev <83857517+OphidieDev@users.noreply.github.com> Date: Mon, 26 May 2025 03:33:28 -0400 Subject: [PATCH 03/21] feat: add basic wally support --- wally.toml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 wally.toml diff --git a/wally.toml b/wally.toml new file mode 100644 index 0000000..24fd98c --- /dev/null +++ b/wally.toml @@ -0,0 +1,7 @@ +[package] +name = "ophidiedev/utf8-validate" +version = "0.1.0" +registry = "https://github.com/UpliftGames/wally-index" +realm = "shared" + +[dependencies] From 4e976bbac718a3a75ad53d2ff1a93cb94dd05c2f Mon Sep 17 00:00:00 2001 From: OphidieDev <83857517+OphidieDev@users.noreply.github.com> Date: Mon, 26 May 2025 03:33:59 -0400 Subject: [PATCH 04/21] feat: add basic init luau file and remove old template files --- src/client/init.client.luau | 1 - src/init.luau | 0 src/server/init.server.luau | 1 - src/shared/Hello.luau | 3 --- 4 files changed, 5 deletions(-) delete mode 100644 src/client/init.client.luau create mode 100644 src/init.luau delete mode 100644 src/server/init.server.luau delete mode 100644 src/shared/Hello.luau diff --git a/src/client/init.client.luau b/src/client/init.client.luau deleted file mode 100644 index 505f71c..0000000 --- a/src/client/init.client.luau +++ /dev/null @@ -1 +0,0 @@ -print("Hello world, from client!") \ No newline at end of file diff --git a/src/init.luau b/src/init.luau new file mode 100644 index 0000000..e69de29 diff --git a/src/server/init.server.luau b/src/server/init.server.luau deleted file mode 100644 index feebef1..0000000 --- a/src/server/init.server.luau +++ /dev/null @@ -1 +0,0 @@ -print("Hello world, from server!") \ No newline at end of file diff --git a/src/shared/Hello.luau b/src/shared/Hello.luau deleted file mode 100644 index c1489a3..0000000 --- a/src/shared/Hello.luau +++ /dev/null @@ -1,3 +0,0 @@ -return function() - print("Hello, world!") -end \ No newline at end of file From cb8ad3652f80a3347d74cc84c1100ba3c5ae4cc5 Mon Sep 17 00:00:00 2001 From: OphidieDev <83857517+OphidieDev@users.noreply.github.com> Date: Mon, 26 May 2025 03:38:50 -0400 Subject: [PATCH 05/21] feat: update project.json to current project directories --- default.project.json | 59 ++++++++++---------------------------------- 1 file changed, 13 insertions(+), 46 deletions(-) diff --git a/default.project.json b/default.project.json index 0bb0a7f..1321516 100644 --- a/default.project.json +++ b/default.project.json @@ -5,68 +5,35 @@ "ReplicatedStorage": { "Shared": { - "$path": "src/shared" + "$path": "src" } }, "ServerScriptService": { - "Server": { - "$path": "src/server" - } + "$className": "ServerScriptService" }, "StarterPlayer": { + "$className": "StarterPlayer", "StarterPlayerScripts": { - "Client": { - "$path": "src/client" - } + "$className": "StarterPlayerScripts" } }, "Workspace": { - "$properties": { - "FilteringEnabled": true - }, - "Baseplate": { - "$className": "Part", - "$properties": { - "Anchored": true, - "Color": [ - 0.38823, - 0.37254, - 0.38823 - ], - "Locked": true, - "Position": [ - 0, - -10, - 0 - ], - "Size": [ - 512, - 20, - 512 - ] - } - } + "$className": "Workspace", + "$properties": { + "FilteringEnabled": true + } }, "Lighting": { - "$properties": { - "Ambient": [ - 0, - 0, - 0 - ], - "Brightness": 2, - "GlobalShadows": true, - "Outlines": false, - "Technology": "Voxel" - } + "$className": "Lighting" }, "SoundService": { - "$properties": { - "RespectFilteringEnabled": true - } + "$className": "SoundService", + "$properties": { + "RespectFilteringEnabled": true + } } } } \ No newline at end of file From f21d4dc4e65c91fe02854af2b7049b07ff2feee4 Mon Sep 17 00:00:00 2001 From: OphidieDev <83857517+OphidieDev@users.noreply.github.com> Date: Mon, 26 May 2025 03:40:50 -0400 Subject: [PATCH 06/21] feat: add empty ci workflow --- .github/workflows/ci.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e69de29 From 6541c4391356796bc8f26c798d4bfcc90b75a233 Mon Sep 17 00:00:00 2001 From: OphidieDev <83857517+OphidieDev@users.noreply.github.com> Date: Mon, 26 May 2025 03:53:14 -0400 Subject: [PATCH 07/21] feat: add language linting/formatters --- .luaurc | 4 ++++ rokit.toml | 2 ++ selene.toml | 24 ++++++++++++++++++++++++ stylua.toml | 2 ++ 4 files changed, 32 insertions(+) create mode 100644 .luaurc create mode 100644 selene.toml create mode 100644 stylua.toml diff --git a/.luaurc b/.luaurc new file mode 100644 index 0000000..688ff2b --- /dev/null +++ b/.luaurc @@ -0,0 +1,4 @@ +{ + "languageMode": "strict", + "lint": { "*": false }, +} \ No newline at end of file diff --git a/rokit.toml b/rokit.toml index 76eb82d..58965b6 100644 --- a/rokit.toml +++ b/rokit.toml @@ -1,3 +1,5 @@ [tools] rojo = "rojo-rbx/rojo@7.5.1" wally = "UpliftGames/wally@0.3.2" +selene = "Kampfkarren/selene@0.28.0" +StyLua = "JohnnyMorganz/StyLua@2.1.0" diff --git a/selene.toml b/selene.toml new file mode 100644 index 0000000..616c16b --- /dev/null +++ b/selene.toml @@ -0,0 +1,24 @@ +std = "luau+roblox" +exclude = [] + +[rules] +almost_swapped = "warn" +divide_by_zero = "warn" +duplicate_keys = "warn" +empty_if = "warn" +global_usage = "warn" +if_same_then_else = "warn" +ifs_same_cond = "warn" +multiple_statements = "warn" +mismatched_arg_count = "warn" +parenthese_conditions = "warn" +roblox_incorrect_color3_new_bounds = "warn" +roblox_incorrect_roact_usage = "warn" +shadowing = "warn" +incorrect_standard_library_use = "warn" +suspicious_reverse_loop = "warn" +type_check_inside_call = "warn" +unbalanced_assignments = "warn" +undefined_variable = "warn" +unscoped_variables = "warn" +unused_variable = "warn" \ No newline at end of file diff --git a/stylua.toml b/stylua.toml new file mode 100644 index 0000000..1d9c417 --- /dev/null +++ b/stylua.toml @@ -0,0 +1,2 @@ +syntax = "Luau" +column_width = 120 \ No newline at end of file From db6960ef706ef45bf8d88a6731d2af663929de51 Mon Sep 17 00:00:00 2001 From: OphidieDev <83857517+OphidieDev@users.noreply.github.com> Date: Mon, 26 May 2025 03:58:24 -0400 Subject: [PATCH 08/21] feat: add ci --- .github/workflows/ci.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e69de29..6495959 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -0,0 +1,35 @@ +name: CI + +on: + pull_request: + branches: [ "main", "dev" ] + + workflow_dispatch: + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: CompeyDev/setup-rokit@v0.1.2 + + - name: Install binary dependencies + run: rokit install --no-trust-check + + - name: Generate Standard Library + run: selene generate-roblox-std + + - name: Run Selene + run: selene . + + format: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: CompeyDev/setup-rokit@v0.1.2 + + - name: Install binary dependencies + run: rokit install --no-trust-check + + - name: Run Stylua + run: stylua --check --syntax luau --output-format Summary src \ No newline at end of file From 741757d696aaa4afcc91421545eb5b610e730d7f Mon Sep 17 00:00:00 2001 From: OphidieDev <83857517+OphidieDev@users.noreply.github.com> Date: Mon, 26 May 2025 04:04:28 -0400 Subject: [PATCH 09/21] feat: add utf8 validator code and license acknowledgement --- README.md | 3 ++ src/init.luau | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) diff --git a/README.md b/README.md index b830594..4fbe4ba 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,5 @@ # utf8-validate A utf8 validator available on many common roblox package managers + +## Licenses +- The original source code for the validator (utf8validator.lua) is MIT Licensed the original source can be found [here](https://github.com/FourierTransformer/utf8validator). diff --git a/src/init.luau b/src/init.luau index e69de29..f169a31 100644 --- a/src/init.luau +++ b/src/init.luau @@ -0,0 +1,91 @@ +local function utf8_validate(input: string): (boolean, number) + local _ + local i, len = 1, #input + local byte, second, third, fourth = 0, 129, 129, 129 + local sbyte = string.byte + local code_points = 0 + while i <= len do + byte = sbyte(input, i) + code_points = code_points + 1 + + if byte <= 127 then + i = i + 1 + --goto none + + elseif byte >= 194 and byte <= 223 then + second = sbyte(input, i + 1) + i = i + 2 + --goto second + + elseif byte == 224 then + second = sbyte(input, i + 1) + third = sbyte(input, i + 2) + + if second ~= nil and second >= 128 and second <= 159 then return false, code_points end + i = i + 3 + --goto third + + elseif byte == 237 then + second = sbyte(input, i + 1) + third = sbyte(input, i + 2) + + if second ~= nil and second >= 160 and second <= 191 then return false, code_points end + i = i + 3 + --goto third + + elseif (byte >= 225 and byte <= 236) or byte == 238 or byte == 239 then + second = sbyte(input, i + 1) + third = sbyte(input, i + 2) + i = i + 3 + --goto third + + elseif byte == 240 then + second = sbyte(input, i + 1) + third = sbyte(input, i + 2) + fourth = sbyte(input, i + 3) + + if second ~= nil and second >= 128 and second <= 143 then return false, code_points end + i = i + 4 + --goto fourth + + elseif byte == 241 or byte == 242 or byte == 243 then + second = sbyte(input, i + 1) + third = sbyte(input, i + 2) + fourth = sbyte(input, i + 3) + i = i + 4 + --goto fourth + + elseif byte == 244 then + second = sbyte(input, i + 1) + third = sbyte(input, i + 2) + fourth = sbyte(input, i + 3) + + if second ~= nil and second >= 160 and second <= 191 then return false, code_points end + i = i + 4 + --goto fourth + + else + + return false, code_points + end + + -- for Lua 5.2+, you can uncomment the goto's above and the lines below for a bit of a speedup + -- ::fourth:: if fourth == nil or fourth < 128 or fourth > 191 then return false, code_points end + -- ::third:: if third == nil or third < 128 or third > 191 then return false, code_points end + -- ::second:: if second == nil or second < 128 or second > 191 then return false, code_points end + -- ::none:: + + -- For Lua, but not LuaJIT, you can offload some of the processing to `find` to speed up validation + -- _, i = input:find(".*", i) + -- i = i + 1 + + -- the below block handles the default use case for Lua 5.1 and LuaJIT + if fourth == nil or fourth < 128 or fourth > 191 then return false, code_points end + if third == nil or third < 128 or third > 191 then return false, code_points end + if second == nil or second < 128 or second > 191 then return false, code_points end + + end + return true, code_points +end + +return utf8_validate \ No newline at end of file From 8d17d80c5d519cea4bea1cb411a3ffbf897c02e4 Mon Sep 17 00:00:00 2001 From: OphidieDev <83857517+OphidieDev@users.noreply.github.com> Date: Mon, 26 May 2025 04:14:38 -0400 Subject: [PATCH 10/21] feat: add basic npm compatible setup --- package.json | 28 ++++++++++++++++++++++++++++ src/index.d.ts | 0 2 files changed, 28 insertions(+) create mode 100644 package.json create mode 100644 src/index.d.ts diff --git a/package.json b/package.json new file mode 100644 index 0000000..417d36e --- /dev/null +++ b/package.json @@ -0,0 +1,28 @@ +{ + "name": "@rbxts/utf8-validate", + "version": "0.1.0", + "description": "UTF8 validator", + "main": "src/init.luau", + "types": "src/index.d.ts", + "scripts": { + "test": "exit 0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/OphidieDev/utf8-validate.git" + }, + "author": "ophidie", + "license": "MIT", + "bugs": { + "url": "https://github.com/OphidieDev/utf8-validate/issues" + }, + "homepage": "https://github.com/OphidieDev/utf8-validate#readme", + "files": [ + "src/**/*", + "!src/**/*.spec.{luau,ts}", + "default.project.json" + ], + "publishConfig": { + "access": "public" + } +} diff --git a/src/index.d.ts b/src/index.d.ts new file mode 100644 index 0000000..e69de29 From 04001aaa09b0e21eff9dc0e4c4cfdcc38bc75951 Mon Sep 17 00:00:00 2001 From: OphidieDev <83857517+OphidieDev@users.noreply.github.com> Date: Mon, 26 May 2025 04:31:54 -0400 Subject: [PATCH 11/21] feat: add index.d.ts for typescript integration --- src/index.d.ts | 7 +++++++ src/init.luau | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/index.d.ts b/src/index.d.ts index e69de29..dd7366f 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -0,0 +1,7 @@ +/** + * Validates whether a given string contains utf8 characters. + * + * @param input The string to validate + * @returns {boolean} Whether or not the string is valid utf8 +*/ +export function utf8_validate(input: string): boolean; \ No newline at end of file diff --git a/src/init.luau b/src/init.luau index f169a31..db2bfa6 100644 --- a/src/init.luau +++ b/src/init.luau @@ -1,4 +1,4 @@ -local function utf8_validate(input: string): (boolean, number) +local function utf8_validate(input: string): boolean local _ local i, len = 1, #input local byte, second, third, fourth = 0, 129, 129, 129 @@ -66,7 +66,7 @@ local function utf8_validate(input: string): (boolean, number) else - return false, code_points + return false end -- for Lua 5.2+, you can uncomment the goto's above and the lines below for a bit of a speedup @@ -85,7 +85,7 @@ local function utf8_validate(input: string): (boolean, number) if second == nil or second < 128 or second > 191 then return false, code_points end end - return true, code_points + return true end return utf8_validate \ No newline at end of file From 50266a589bfff4e684878720024191758cb87db2 Mon Sep 17 00:00:00 2001 From: OphidieDev <83857517+OphidieDev@users.noreply.github.com> Date: Mon, 26 May 2025 04:35:22 -0400 Subject: [PATCH 12/21] build: change name of package in rojo tree --- default.project.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default.project.json b/default.project.json index 1321516..0a5808f 100644 --- a/default.project.json +++ b/default.project.json @@ -4,7 +4,7 @@ "$className": "DataModel", "ReplicatedStorage": { - "Shared": { + "utf8_validate": { "$path": "src" } }, From 8ea3de29b8527a4c18388dc91230b672488b97b7 Mon Sep 17 00:00:00 2001 From: OphidieDev <83857517+OphidieDev@users.noreply.github.com> Date: Mon, 26 May 2025 04:37:23 -0400 Subject: [PATCH 13/21] feat: update grammar in index.d.ts --- src/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.d.ts b/src/index.d.ts index dd7366f..60c1ed8 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -1,5 +1,5 @@ /** - * Validates whether a given string contains utf8 characters. + * Validates whether a given string contains only utf8 characters. * * @param input The string to validate * @returns {boolean} Whether or not the string is valid utf8 From 66f98f60bd5796afab9b132f8fece91c06182900 Mon Sep 17 00:00:00 2001 From: OphidieDev <83857517+OphidieDev@users.noreply.github.com> Date: Mon, 26 May 2025 04:58:12 -0400 Subject: [PATCH 14/21] build: swap to default version 1.0.0 --- package.json | 14 +++++++------- pesde.toml | 2 +- wally.toml | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 417d36e..0914656 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,12 @@ { "name": "@rbxts/utf8-validate", - "version": "0.1.0", + "version": "1.0.0", "description": "UTF8 validator", "main": "src/init.luau", "types": "src/index.d.ts", "scripts": { - "test": "exit 0" - }, + "test": "exit 0" + }, "repository": { "type": "git", "url": "git+https://github.com/OphidieDev/utf8-validate.git" @@ -14,13 +14,13 @@ "author": "ophidie", "license": "MIT", "bugs": { - "url": "https://github.com/OphidieDev/utf8-validate/issues" + "url": "https://github.com/OphidieDev/utf8-validate/issues" }, "homepage": "https://github.com/OphidieDev/utf8-validate#readme", "files": [ - "src/**/*", - "!src/**/*.spec.{luau,ts}", - "default.project.json" + "src/**/*", + "!src/**/*.spec.{luau,ts}", + "default.project.json" ], "publishConfig": { "access": "public" diff --git a/pesde.toml b/pesde.toml index 9babd51..e809bdb 100644 --- a/pesde.toml +++ b/pesde.toml @@ -1,5 +1,5 @@ name = "ophidiedev/utf8_validate" -version = "0.1.0" +version = "1.0.0" description = "UTF8 validator" repository = "https://github.com/OphidieDev/utf8-validate" license = "MIT" diff --git a/wally.toml b/wally.toml index 24fd98c..44c211e 100644 --- a/wally.toml +++ b/wally.toml @@ -1,6 +1,6 @@ [package] name = "ophidiedev/utf8-validate" -version = "0.1.0" +version = "1.0.0" registry = "https://github.com/UpliftGames/wally-index" realm = "shared" From b34b99e45699939a5f19f312221d44bc439b491c Mon Sep 17 00:00:00 2001 From: OphidieDev <83857517+OphidieDev@users.noreply.github.com> Date: Mon, 26 May 2025 04:59:28 -0400 Subject: [PATCH 15/21] chore: update readme to include various instructions and vanity improvements --- README.md | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4fbe4ba..fb47239 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,35 @@ -# utf8-validate -A utf8 validator available on many common roblox package managers +

+

utf8-validate

+

+ A utf8 validator written in luau +
+

+

+ +> [!NOTE] +> The original source code for the validator used in this project can be found [here](https://github.com/FourierTransformer/utf8validator) + +## Features +- Validate whether a string contains only valid utf8 characters + +## Installation +Add to your `wally.toml`: +```toml +utf8_validate = "ophidiedev/utf8-validate@1.0.0" +``` + +Add to your `pesde.toml`: +```toml +utf8_validate = { name = "ophidiedev/utf8_validate", version = "^1.0.0" } +``` + +Add to your `package.json`: +```json +"@rbxts/utf8-validate": "^1.0.0" +``` + +## Read More +If you are interested in reading more about the problem this package solves, consider reading [this story](https://blog.vorlias.nz/2023/09/breaking-an-economy-using-a-sign) by community member [Vorlias](https://vorlias.nz/). ## Licenses - The original source code for the validator (utf8validator.lua) is MIT Licensed the original source can be found [here](https://github.com/FourierTransformer/utf8validator). From 96cd9d429f72a81c5d092f41b3770539a779d0fa Mon Sep 17 00:00:00 2001 From: OphidieDev <83857517+OphidieDev@users.noreply.github.com> Date: Mon, 26 May 2025 06:58:38 -0400 Subject: [PATCH 16/21] chore: update gitignore --- .gitignore | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 8d7ca01..14e2d4d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ # Project place file /utf8-validate.rbxlx -# Roblox Studio lock files -/*.rbxlx.lock -/*.rbxl.lock \ No newline at end of file +# Selene +roblox.yml + +/*.lock + +sourcemap.json \ No newline at end of file From dfb564f642289bc0cd49adf647699d9ec42b5a32 Mon Sep 17 00:00:00 2001 From: OphidieDev <83857517+OphidieDev@users.noreply.github.com> Date: Mon, 26 May 2025 06:59:20 -0400 Subject: [PATCH 17/21] chore: update casing for stylua in rokit --- rokit.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rokit.toml b/rokit.toml index 58965b6..f18bbcc 100644 --- a/rokit.toml +++ b/rokit.toml @@ -2,4 +2,4 @@ rojo = "rojo-rbx/rojo@7.5.1" wally = "UpliftGames/wally@0.3.2" selene = "Kampfkarren/selene@0.28.0" -StyLua = "JohnnyMorganz/StyLua@2.1.0" +stylua = "JohnnyMorganz/StyLua@2.1.0" From 68a9f828c4629a532a09aa96edec3406d5fb8014 Mon Sep 17 00:00:00 2001 From: OphidieDev <83857517+OphidieDev@users.noreply.github.com> Date: Mon, 26 May 2025 07:06:12 -0400 Subject: [PATCH 18/21] feat: update stylua formatting rules --- stylua.toml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stylua.toml b/stylua.toml index 1d9c417..e12ca1a 100644 --- a/stylua.toml +++ b/stylua.toml @@ -1,2 +1,4 @@ syntax = "Luau" -column_width = 120 \ No newline at end of file +column_width = 120 +indent_type = "Tabs" +indent_width = 4 \ No newline at end of file From 02bd0a1bd3f04cadcffb09e5880d13049c1cb026 Mon Sep 17 00:00:00 2001 From: OphidieDev <83857517+OphidieDev@users.noreply.github.com> Date: Mon, 26 May 2025 07:06:29 -0400 Subject: [PATCH 19/21] chore: update formatting in main luau file --- src/init.luau | 180 ++++++++++++++++++++++++++------------------------ 1 file changed, 92 insertions(+), 88 deletions(-) diff --git a/src/init.luau b/src/init.luau index db2bfa6..ddb41b1 100644 --- a/src/init.luau +++ b/src/init.luau @@ -1,91 +1,95 @@ local function utf8_validate(input: string): boolean - local _ - local i, len = 1, #input - local byte, second, third, fourth = 0, 129, 129, 129 - local sbyte = string.byte - local code_points = 0 - while i <= len do - byte = sbyte(input, i) - code_points = code_points + 1 - - if byte <= 127 then - i = i + 1 - --goto none - - elseif byte >= 194 and byte <= 223 then - second = sbyte(input, i + 1) - i = i + 2 - --goto second - - elseif byte == 224 then - second = sbyte(input, i + 1) - third = sbyte(input, i + 2) - - if second ~= nil and second >= 128 and second <= 159 then return false, code_points end - i = i + 3 - --goto third - - elseif byte == 237 then - second = sbyte(input, i + 1) - third = sbyte(input, i + 2) - - if second ~= nil and second >= 160 and second <= 191 then return false, code_points end - i = i + 3 - --goto third - - elseif (byte >= 225 and byte <= 236) or byte == 238 or byte == 239 then - second = sbyte(input, i + 1) - third = sbyte(input, i + 2) - i = i + 3 - --goto third - - elseif byte == 240 then - second = sbyte(input, i + 1) - third = sbyte(input, i + 2) - fourth = sbyte(input, i + 3) - - if second ~= nil and second >= 128 and second <= 143 then return false, code_points end - i = i + 4 - --goto fourth - - elseif byte == 241 or byte == 242 or byte == 243 then - second = sbyte(input, i + 1) - third = sbyte(input, i + 2) - fourth = sbyte(input, i + 3) - i = i + 4 - --goto fourth - - elseif byte == 244 then - second = sbyte(input, i + 1) - third = sbyte(input, i + 2) - fourth = sbyte(input, i + 3) - - if second ~= nil and second >= 160 and second <= 191 then return false, code_points end - i = i + 4 - --goto fourth - - else - - return false - end - - -- for Lua 5.2+, you can uncomment the goto's above and the lines below for a bit of a speedup - -- ::fourth:: if fourth == nil or fourth < 128 or fourth > 191 then return false, code_points end - -- ::third:: if third == nil or third < 128 or third > 191 then return false, code_points end - -- ::second:: if second == nil or second < 128 or second > 191 then return false, code_points end - -- ::none:: - - -- For Lua, but not LuaJIT, you can offload some of the processing to `find` to speed up validation - -- _, i = input:find(".*", i) - -- i = i + 1 - - -- the below block handles the default use case for Lua 5.1 and LuaJIT - if fourth == nil or fourth < 128 or fourth > 191 then return false, code_points end - if third == nil or third < 128 or third > 191 then return false, code_points end - if second == nil or second < 128 or second > 191 then return false, code_points end - - end - return true + local _ + local i, len = 1, #input + local byte, second, third, fourth = 0, 129, 129, 129 + local sbyte = string.byte + local code_points = 0 + while i <= len do + byte = sbyte(input, i) + code_points = code_points + 1 + + if byte <= 127 then + i = i + 1 + --goto none + elseif byte >= 194 and byte <= 223 then + second = sbyte(input, i + 1) + i = i + 2 + --goto second + elseif byte == 224 then + second = sbyte(input, i + 1) + third = sbyte(input, i + 2) + + if second ~= nil and second >= 128 and second <= 159 then + return false, code_points + end + i = i + 3 + --goto third + elseif byte == 237 then + second = sbyte(input, i + 1) + third = sbyte(input, i + 2) + + if second ~= nil and second >= 160 and second <= 191 then + return false, code_points + end + i = i + 3 + --goto third + elseif (byte >= 225 and byte <= 236) or byte == 238 or byte == 239 then + second = sbyte(input, i + 1) + third = sbyte(input, i + 2) + i = i + 3 + --goto third + elseif byte == 240 then + second = sbyte(input, i + 1) + third = sbyte(input, i + 2) + fourth = sbyte(input, i + 3) + + if second ~= nil and second >= 128 and second <= 143 then + return false, code_points + end + i = i + 4 + --goto fourth + elseif byte == 241 or byte == 242 or byte == 243 then + second = sbyte(input, i + 1) + third = sbyte(input, i + 2) + fourth = sbyte(input, i + 3) + i = i + 4 + --goto fourth + elseif byte == 244 then + second = sbyte(input, i + 1) + third = sbyte(input, i + 2) + fourth = sbyte(input, i + 3) + + if second ~= nil and second >= 160 and second <= 191 then + return false, code_points + end + i = i + 4 + --goto fourth + else + return false + end + + -- for Lua 5.2+, you can uncomment the goto's above and the lines below for a bit of a speedup + -- ::fourth:: if fourth == nil or fourth < 128 or fourth > 191 then return false, code_points end + -- ::third:: if third == nil or third < 128 or third > 191 then return false, code_points end + -- ::second:: if second == nil or second < 128 or second > 191 then return false, code_points end + -- ::none:: + + -- For Lua, but not LuaJIT, you can offload some of the processing to `find` to speed up validation + -- _, i = input:find(".*", i) + -- i = i + 1 + + -- the below block handles the default use case for Lua 5.1 and LuaJIT + if fourth == nil or fourth < 128 or fourth > 191 then + return false, code_points + end + if third == nil or third < 128 or third > 191 then + return false, code_points + end + if second == nil or second < 128 or second > 191 then + return false, code_points + end + end + return true end -return utf8_validate \ No newline at end of file +return utf8_validate From b22c2b0a036057947d2b39cc194017f37d460722 Mon Sep 17 00:00:00 2001 From: OphidieDev <83857517+OphidieDev@users.noreply.github.com> Date: Mon, 26 May 2025 08:38:55 -0400 Subject: [PATCH 20/21] chore: update readme with shields icons --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index fb47239..f2fe98f 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,12 @@

+

+ [![Version npm](https://img.shields.io/npm/v/@rbxts/utf8-validate.svg?logo=npm)](https://www.npmjs.com/package/@rbxts/utf8-validate) + pesde + wally +

+ > [!NOTE] > The original source code for the validator used in this project can be found [here](https://github.com/FourierTransformer/utf8validator) From 4c857d3af924af76a4f53508152625776030c03b Mon Sep 17 00:00:00 2001 From: OphidieDev <83857517+OphidieDev@users.noreply.github.com> Date: Mon, 26 May 2025 08:47:22 -0400 Subject: [PATCH 21/21] chore: add license --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..68f53e0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 OphidieDev + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file